From 447cf710af6311974b4cd465845ed0bfd9c182cf Mon Sep 17 00:00:00 2001 From: Daniel Malon Date: Thu, 26 Feb 2015 21:29:00 +0000 Subject: [PATCH] Add configurable assets folder This adds a server-assets-folder configuration which allows overriding the assets bundled to the binary. --- packaging/root/etc/drone/drone.toml | 6 ++++++ server/main.go | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packaging/root/etc/drone/drone.toml b/packaging/root/etc/drone/drone.toml index b5ec9c3c..a28f117a 100644 --- a/packaging/root/etc/drone/drone.toml +++ b/packaging/root/etc/drone/drone.toml @@ -9,6 +9,12 @@ port=":80" # key="" # cert="" +##################################################################### +# Assets configuration +# +# [server.assets] +# folder="" + # [session] # secret="" # expires="" diff --git a/server/main.go b/server/main.go index 9d65a2bc..bd5e0bca 100644 --- a/server/main.go +++ b/server/main.go @@ -55,6 +55,8 @@ var ( sslcrt = config.String("server-ssl-cert", "") sslkey = config.String("server-ssl-key", "") + assets_folder = config.String("server-assets-folder", "") + workers *pool.Pool worker *director.Director pub *pubsub.PubSub @@ -125,7 +127,15 @@ func main() { pub = pubsub.NewPubSub() // 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("/static/", http.StripPrefix("/static", assetserve)) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {