Skip to content

Commit

Permalink
feat(icons): set cache fields for icons response
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonish committed Sep 2, 2024
1 parent 8323f05 commit ccb0989
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions internal/pages/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,24 @@ func Pages(router *gin.Engine) {

router.LoadHTMLFiles(htmlTemplates...)
iconsFs, _ := fs.Sub(mFs, MEM_ICONS_DIR)
router.StaticFS("/assets/icons", http.FS(iconsFs))
router.StaticFS("/assets/uploads", gin.Dir(model.UPLOAD_FILES_PATH, false))
uploadsFs := gin.Dir(model.UPLOAD_FILES_PATH, false)

router.Static("/assets/js", model.JS_PATH)
router.Static("/assets/css", model.CSS_PATH)
router.Static("/manager-assets", model.MANAGER_PATH+"/manager-assets")

router.GET("/assets/icons/*filepath", func(ctx *gin.Context) {
filepath := ctx.Param("filepath")
setCacheHeader(ctx)
ctx.FileFromFS(filepath, http.FS(iconsFs))
})

router.GET("/assets/uploads/*filepath", func(ctx *gin.Context) {
filepath := ctx.Param("filepath")
setCacheHeader(ctx)
ctx.FileFromFS(filepath, uploadsFs)
})

home(router)
login(router)
logout(router)
Expand Down

0 comments on commit ccb0989

Please sign in to comment.