conf: new Web>ExternalWebroot key to load from /client/ directory

This commit is contained in:
mappu 2017-02-05 15:37:27 +13:00
parent 656125e790
commit d5e8e051e3
2 changed files with 7 additions and 1 deletions

View File

@ -12,6 +12,8 @@ type Config struct {
BindTo string `json:"bind_to"` BindTo string `json:"bind_to"`
Extern string `json:"extern"` Extern string `json:"extern"`
Title string `json:"title"` Title string `json:"title"`
ExternalWebroot bool `json:"external_webroot,omitempty"`
} }
Hub struct { Hub struct {

View File

@ -229,7 +229,11 @@ func (this *App) RunServer() {
http.HandleFunc("/conf", this.ConfigRequestHandler) http.HandleFunc("/conf", this.ConfigRequestHandler)
// Other files: asset handler // Other files: asset handler
http.HandleFunc("/", this.StaticRequestHandler) if this.cfg.Web.ExternalWebroot {
http.Handle("/", http.FileServer(http.Dir("client")))
} else {
http.HandleFunc("/", this.StaticRequestHandler)
}
// Listen and serve // Listen and serve
bindAddr := fmt.Sprintf("%s:%d", this.cfg.Web.BindTo, this.cfg.Web.Port) bindAddr := fmt.Sprintf("%s:%d", this.cfg.Web.BindTo, this.cfg.Web.Port)