From c4572ebc91288957356de519a178e9dd21da09e3 Mon Sep 17 00:00:00 2001 From: Xiaoxing Ye Date: Fri, 24 Apr 2020 03:22:47 +0800 Subject: [PATCH] rc: fix misplaced http server config - fixes #4130 --- fs/rc/rcserver/rcserver.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/fs/rc/rcserver/rcserver.go b/fs/rc/rcserver/rcserver.go index bf0e4db90..ac24c6152 100644 --- a/fs/rc/rcserver/rcserver.go +++ b/fs/rc/rcserver/rcserver.go @@ -62,12 +62,7 @@ type Server struct { } func newServer(opt *rc.Options, mux *http.ServeMux) *Server { - s := &Server{ - Server: httplib.NewServer(mux, &opt.HTTPOptions), - opt: opt, - } - mux.HandleFunc("/", s.handler) - + fileHandler := http.Handler(nil) // Add some more mime types which are often missing _ = mime.AddExtensionType(".wasm", "application/wasm") _ = mime.AddExtensionType(".js", "application/javascript") @@ -80,7 +75,7 @@ func newServer(opt *rc.Options, mux *http.ServeMux) *Server { fs.Logf(nil, "--rc-files overrides --rc-web-gui command\n") } fs.Logf(nil, "Serving files from %q", opt.Files) - s.files = http.FileServer(http.Dir(opt.Files)) + fileHandler = http.FileServer(http.Dir(opt.Files)) } else if opt.WebUI { if err := rc.CheckAndDownloadWebGUIRelease(opt.WebGUIUpdate, opt.WebGUIForceUpdate, opt.WebGUIFetchURL, config.CacheDir); err != nil { log.Fatalf("Error while fetching the latest release of Web GUI: %v", err) @@ -104,8 +99,16 @@ func newServer(opt *rc.Options, mux *http.ServeMux) *Server { opt.Serve = true fs.Logf(nil, "Serving Web GUI") - s.files = http.FileServer(http.Dir(extractPath)) + fileHandler = http.FileServer(http.Dir(extractPath)) } + + s := &Server{ + Server: httplib.NewServer(mux, &opt.HTTPOptions), + opt: opt, + files: fileHandler, + } + mux.HandleFunc("/", s.handler) + return s }