Allow user to specify assets path in settings

Fixes #2
This commit is contained in:
Maddie Zhan
2020-06-16 15:34:29 +08:00
parent 8971ba8117
commit bd721cdb07
6 changed files with 18 additions and 4 deletions

View File

@ -81,9 +81,11 @@ func pages(w http.ResponseWriter, r *http.Request) {
r.RequestURI = "/index.html"
}
conf := config.LoadedConfig()
uri := strings.Split(r.RequestURI, "?")[0]
if strings.HasSuffix(uri, ".html") || strings.HasSuffix(uri, ".js") {
http.FileServer(http.Dir("assets")).ServeHTTP(w, r)
http.FileServer(http.Dir(conf.AssetsPath)).ServeHTTP(w, r)
} else {
w.WriteHeader(http.StatusForbidden)
}