fix: static

This commit is contained in:
Sergey Solodyagin
2024-12-19 14:54:58 +03:00
parent af882e46c3
commit d21f7d6fda
+2 -1
View File
@@ -3,6 +3,7 @@ package static
import (
"fmt"
"net/http"
"strings"
"git.company.lan/gopkg/gin"
)
@@ -31,7 +32,7 @@ func ServeCached(urlPrefix string, fs ServeFileSystem, cacheAge uint) gin.Handle
fileserver = http.StripPrefix(urlPrefix, fileserver)
}
return func(c *gin.Context) {
if fs.Exists(urlPrefix, c.Request.URL.Path) && !fs.Override(c) {
if strings.HasPrefix(c.Request.URL.Path, urlPrefix) && fs.Exists(urlPrefix, c.Request.URL.Path) && !fs.Override(c) {
if cacheAge != 0 {
c.Writer.Header().Add("Cache-Control", fmt.Sprintf("max-age=%d", cacheAge))
}