fix StaticFS

This commit is contained in:
wjqserver 2025-09-14 08:24:01 +08:00
parent 38ff5126e3
commit 5b98310de5

View file

@ -244,7 +244,7 @@ func (engine *Engine) StaticFS(relativePath string, fs http.FileSystem) {
relativePath += "/" relativePath += "/"
} }
fileServer := http.FileServer(fs) fileServer := http.StripPrefix(relativePath, http.FileServer(fs))
engine.ANY(relativePath+"*filepath", GetStaticFSHandleFunc(fileServer)) engine.ANY(relativePath+"*filepath", GetStaticFSHandleFunc(fileServer))
} }
@ -258,7 +258,7 @@ func (group *RouterGroup) StaticFS(relativePath string, fs http.FileSystem) {
relativePath += "/" relativePath += "/"
} }
fileServer := http.FileServer(fs) fileServer := http.StripPrefix(relativePath, http.FileServer(fs))
group.ANY(relativePath+"*filepath", GetStaticFSHandleFunc(fileServer)) group.ANY(relativePath+"*filepath", GetStaticFSHandleFunc(fileServer))
} }