Give sensible name to caching method
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ed9e75d57a
commit
5018e5b973
@ -42,7 +42,7 @@ func (h *Handler) Serve() {
|
||||
if err != nil {
|
||||
panic("couldn't open static files")
|
||||
}
|
||||
router.Use(headersByRequestURI())
|
||||
router.Use(enableCachingForStaticFiles())
|
||||
router.StaticFS("/static", http.FS(static))
|
||||
|
||||
router.GET("/", func(c *gin.Context) { c.HTML(http.StatusOK, "index.html", nil) })
|
||||
@ -92,7 +92,7 @@ func (h *Handler) Serve() {
|
||||
router.Run(":1323")
|
||||
}
|
||||
|
||||
func headersByRequestURI() gin.HandlerFunc {
|
||||
func enableCachingForStaticFiles() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
if strings.HasPrefix(c.Request.RequestURI, "/static/") {
|
||||
c.Header("Cache-Control", "max-age=86400")
|
||||
|
Loading…
x
Reference in New Issue
Block a user