diff --git a/routes/dirlist.go b/routes/dirlist.go index 99113c6..6733c5a 100644 --- a/routes/dirlist.go +++ b/routes/dirlist.go @@ -49,6 +49,9 @@ type fileInfo struct { } func (r *routeCtx) handleDirList(rw http.ResponseWriter, req *http.Request) { + if req.Method == http.MethodHead { + return + } openDir, err := os.ReadDir(filepath.Join(r.basePath, req.URL.Path)) if err != nil { http.Error(rw, "404 Not Found", http.StatusNotFound) diff --git a/routes/dirlist.go.html b/routes/dirlist.go.html index 86d18b5..90aa6c4 100644 --- a/routes/dirlist.go.html +++ b/routes/dirlist.go.html @@ -29,6 +29,11 @@ Last Modified Size + + ../ + + + {{range .Files}} {{ .Name }} diff --git a/routes/router.go b/routes/router.go index 05fead7..64bbb02 100644 --- a/routes/router.go +++ b/routes/router.go @@ -59,8 +59,10 @@ func Router(db *database.Queries, name, basePath string, repository []string) ht rWeb := httprouter.New() rWeb.PUT("/*filepath", base.repoAuth(base.handlePut)) rWeb.GET("/", base.handleFiles) + rWeb.HEAD("/", base.handleFiles) for _, repo := range repository { rWeb.GET(path.Join("/", repo, "*filepath"), base.handleFiles) + rWeb.HEAD(path.Join("/", repo, "*filepath"), base.handleFiles) } mux := http.NewServeMux()