Give sensible name to caching method
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Jan Bader 2021-12-28 20:16:44 +00:00
parent ed9e75d57a
commit 5018e5b973

View File

@ -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")