fix: static
This commit is contained in:
+2
-1
@@ -3,6 +3,7 @@ package static
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"git.company.lan/gopkg/gin"
|
"git.company.lan/gopkg/gin"
|
||||||
)
|
)
|
||||||
@@ -31,7 +32,7 @@ func ServeCached(urlPrefix string, fs ServeFileSystem, cacheAge uint) gin.Handle
|
|||||||
fileserver = http.StripPrefix(urlPrefix, fileserver)
|
fileserver = http.StripPrefix(urlPrefix, fileserver)
|
||||||
}
|
}
|
||||||
return func(c *gin.Context) {
|
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 {
|
if cacheAge != 0 {
|
||||||
c.Writer.Header().Add("Cache-Control", fmt.Sprintf("max-age=%d", cacheAge))
|
c.Writer.Header().Add("Cache-Control", fmt.Sprintf("max-age=%d", cacheAge))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user