Return 404 for non-existing files instead of 403

This commit is contained in:
Maddie Zhan
2020-08-15 23:13:23 +08:00
parent 2958853375
commit 6970d87166
2 changed files with 56 additions and 7 deletions
+2 -7
View File
@@ -91,13 +91,8 @@ func pages(w http.ResponseWriter, r *http.Request) {
}
conf := config.LoadedConfig()
uri := strings.Split(r.RequestURI, "?")[0]
if strings.HasSuffix(uri, ".html") || strings.HasSuffix(uri, ".js") {
http.FileServer(http.Dir(conf.AssetsPath)).ServeHTTP(w, r)
} else {
w.WriteHeader(http.StatusForbidden)
}
fs := justFilesFilesystem{fs: http.Dir(conf.AssetsPath), readDirBatchSize: 2}
http.FileServer(fs).ServeHTTP(w, r)
}
func empty(w http.ResponseWriter, r *http.Request) {