fix: add no cache to static
This commit is contained in:
parent
eee8ec42c5
commit
4d8632e26c
3
main.go
3
main.go
@ -32,7 +32,6 @@ func main() {
|
|||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
|
|
||||||
r.LoadHTMLGlob("templates/*")
|
r.LoadHTMLGlob("templates/*")
|
||||||
r.Static("/static", "./public")
|
|
||||||
|
|
||||||
r.Use(gin.Recovery())
|
r.Use(gin.Recovery())
|
||||||
r.Use(middleware.XssPreventionHeaders())
|
r.Use(middleware.XssPreventionHeaders())
|
||||||
@ -40,6 +39,8 @@ func main() {
|
|||||||
r.Use(middleware.OptionsMiddleware())
|
r.Use(middleware.OptionsMiddleware())
|
||||||
r.Use(middleware.Ratelimit())
|
r.Use(middleware.Ratelimit())
|
||||||
|
|
||||||
|
r.GET("/static/*filepath", routes.StaticContent)
|
||||||
|
|
||||||
r.GET("/robots.txt", func(c *gin.Context) {
|
r.GET("/robots.txt", func(c *gin.Context) {
|
||||||
c.String(200, "User-agent: *\nDisallow: /")
|
c.String(200, "User-agent: *\nDisallow: /")
|
||||||
})
|
})
|
||||||
|
14
src/routes/static.go
Normal file
14
src/routes/static.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package routes
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func StaticContent(c *gin.Context) {
|
||||||
|
cleanFilePath := strings.ReplaceAll(c.Param("filepath"), "..", "")
|
||||||
|
|
||||||
|
c.File(fmt.Sprintf("./public/%s", cleanFilePath))
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user