Disabling static directory listing (#4919)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
2a91e5e031
Коммит
267257b680
@@ -37,6 +37,10 @@ func InitWeb() {
|
|||||||
func staticHandler(handler http.Handler) http.Handler {
|
func staticHandler(handler http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Cache-Control", "max-age=31556926, public")
|
w.Header().Set("Cache-Control", "max-age=31556926, public")
|
||||||
|
if strings.HasSuffix(r.URL.Path, "/") {
|
||||||
|
http.NotFound(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
handler.ServeHTTP(w, r)
|
handler.ServeHTTP(w, r)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user