internal: disable directory listing on static files

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-09-04 13:29:44 +02:00
parent f725009530
commit 126e43dea4
2 changed files with 35 additions and 7 deletions

View File

@ -0,0 +1,17 @@
package web
import (
"net/http"
"strings"
)
func disableIndex(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.HasSuffix(r.URL.Path, "/") {
http.NotFound(w, r)
return
}
next.ServeHTTP(w, r)
})
}