fix static files serving Path.

This commit is contained in:
Miroslav Šedivý 2021-03-21 21:42:53 +01:00
parent e4d82673da
commit 52e586790e

View File

@ -52,10 +52,10 @@ func New(WebSocketManager types.WebSocketManager, ApiManager types.ApiManager, c
if conf.Static != "" {
fs := http.FileServer(http.Dir(conf.Static))
router.Get("/*", func(w http.ResponseWriter, r *http.Request) {
if _, err := os.Stat(conf.Static + r.RequestURI); os.IsNotExist(err) {
http.StripPrefix(r.RequestURI, fs).ServeHTTP(w, r)
} else {
if _, err := os.Stat(conf.Static + r.URL.Path); !os.IsNotExist(err) {
fs.ServeHTTP(w, r)
} else {
utils.HttpNotFound(w)
}
})
}