mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-02-16 18:34:28 +02:00
Merge pull request #901 from MerlinDMC/feature/serve-static-folder
Make bundled assets overridable
This commit is contained in:
commit
aa4b38ceb1
@ -9,6 +9,12 @@ port=":80"
|
|||||||
# key=""
|
# key=""
|
||||||
# cert=""
|
# cert=""
|
||||||
|
|
||||||
|
#####################################################################
|
||||||
|
# Assets configuration
|
||||||
|
#
|
||||||
|
# [server.assets]
|
||||||
|
# folder=""
|
||||||
|
|
||||||
# [session]
|
# [session]
|
||||||
# secret=""
|
# secret=""
|
||||||
# expires=""
|
# expires=""
|
||||||
|
@ -55,6 +55,8 @@ var (
|
|||||||
sslcrt = config.String("server-ssl-cert", "")
|
sslcrt = config.String("server-ssl-cert", "")
|
||||||
sslkey = config.String("server-ssl-key", "")
|
sslkey = config.String("server-ssl-key", "")
|
||||||
|
|
||||||
|
assets_folder = config.String("server-assets-folder", "")
|
||||||
|
|
||||||
workers *pool.Pool
|
workers *pool.Pool
|
||||||
worker *director.Director
|
worker *director.Director
|
||||||
pub *pubsub.PubSub
|
pub *pubsub.PubSub
|
||||||
@ -125,7 +127,15 @@ func main() {
|
|||||||
pub = pubsub.NewPubSub()
|
pub = pubsub.NewPubSub()
|
||||||
|
|
||||||
// create handler for static resources
|
// create handler for static resources
|
||||||
assetserve := http.FileServer(rice.MustFindBox("app").HTTPBox())
|
// if we have a configured assets folder it takes precedence over the assets
|
||||||
|
// bundled to the binary
|
||||||
|
var assetserve http.Handler
|
||||||
|
if *assets_folder != "" {
|
||||||
|
assetserve = http.FileServer(http.Dir(*assets_folder))
|
||||||
|
} else {
|
||||||
|
assetserve = http.FileServer(rice.MustFindBox("app").HTTPBox())
|
||||||
|
}
|
||||||
|
|
||||||
http.Handle("/robots.txt", assetserve)
|
http.Handle("/robots.txt", assetserve)
|
||||||
http.Handle("/static/", http.StripPrefix("/static", assetserve))
|
http.Handle("/static/", http.StripPrefix("/static", assetserve))
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user