From 312cd7c9bddf3280c4aac6b438221289e34a8182 Mon Sep 17 00:00:00 2001 From: aleimu Date: Sat, 12 Oct 2024 16:44:55 +0800 Subject: [PATCH] Fix the error in createStaticHandler when handling directories and index.html files --- routergroup.go | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/routergroup.go b/routergroup.go index b2540ec11e..1bc7cf42f3 100644 --- a/routergroup.go +++ b/routergroup.go @@ -221,19 +221,6 @@ func (group *RouterGroup) createStaticHandler(relativePath string, fs http.FileS if _, noListing := fs.(*OnlyFilesFS); noListing { c.Writer.WriteHeader(http.StatusNotFound) } - - file := c.Param("filepath") - // Check if file exists and/or if we have permission to access it - f, err := fs.Open(file) - if err != nil { - c.Writer.WriteHeader(http.StatusNotFound) - c.handlers = group.engine.noRoute - // Reset index - c.index = -1 - return - } - f.Close() - fileServer.ServeHTTP(c.Writer, c.Request) } }