diff --git a/Config.go b/Config.go index f98e361..0780e0a 100644 --- a/Config.go +++ b/Config.go @@ -6,10 +6,11 @@ type Config struct { } Web struct { - Port int `json:"port"` - BindTo string `json:"bind_to"` - Extern string `json:"extern"` - Title string `json:"title"` + Port int `json:"port"` + BindTo string `json:"bind_to"` + Extern string `json:"extern"` + Title string `json:"title"` + CustomFavicon bool `json:"custom_favicon"` ExternalWebroot bool `json:"external_webroot,omitempty"` } diff --git a/main.go b/main.go index a50e002..26c612a 100644 --- a/main.go +++ b/main.go @@ -181,6 +181,10 @@ func (this *App) SocketIOServer(so socketio.Socket) { } +func (this *App) customFaviconHandler(w http.ResponseWriter, r *http.Request) { + http.ServeFile(w, r, "favicon.ico") +} + func (this *App) ConfigRequestHandler(w http.ResponseWriter, r *http.Request) { confStruct := struct { @@ -213,9 +217,9 @@ func (this *App) StaticRequestHandler(w http.ResponseWriter, r *http.Request) { knownContentTypes := map[string]string{ ".htm": "text/html", - ".css": "text/css", - ".js": "application/javascript", ".png": "image/png", + ".ico": "image/x-icon", + // No CSS/JS since they're embedded in the HTML } foundMime := false @@ -251,6 +255,10 @@ func (this *App) RunServer() { // Configuration handler http.HandleFunc("/conf", this.ConfigRequestHandler) + if this.cfg.Web.CustomFavicon { + http.HandleFunc("/favicon.ico", this.customFaviconHandler) + } + // Other files: asset handler if this.cfg.Web.ExternalWebroot { http.Handle("/", http.FileServer(http.Dir("client"))) diff --git a/nmdc-webfrontend.conf.SAMPLE b/nmdc-webfrontend.conf.SAMPLE index 1644da8..52a2056 100644 --- a/nmdc-webfrontend.conf.SAMPLE +++ b/nmdc-webfrontend.conf.SAMPLE @@ -8,7 +8,8 @@ "port" : 8082, "bind_to": "127.0.0.1", "extern" : "http://127.0.0.1:8082", - "title" : "DCWebUI" + "title" : "DCWebUI", + "custom_favicon": false }, "hub": {