diff options
author | Mo Tarbin <mhed.t91@gmail.com> | 2024-07-24 01:10:34 -0400 |
---|---|---|
committer | Mo Tarbin <mhed.t91@gmail.com> | 2024-07-24 01:10:34 -0400 |
commit | 3071ff12cf2bd06b18596275771195ca711bc024 (patch) | |
tree | 682501f9238ef9cbc8581779a26d752556afc3b4 /frontend | |
parent | a35496c9223018471b51aecac9bf4e3a1387883c (diff) | |
parent | be98920271e9f1a8becb1dbf91be721380a81bb3 (diff) | |
download | donetick-3071ff12cf2bd06b18596275771195ca711bc024.tar.gz donetick-3071ff12cf2bd06b18596275771195ca711bc024.tar.bz2 donetick-3071ff12cf2bd06b18596275771195ca711bc024.zip |
Merge branch 'dev'
Diffstat (limited to '')
-rw-r--r-- | frontend/handler.go | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/frontend/handler.go b/frontend/handler.go index 1a5337e..87ae17c 100644 --- a/frontend/handler.go +++ b/frontend/handler.go @@ -5,6 +5,7 @@ import ( "io/fs" "net/http" + "donetick.com/core/config" "github.com/gin-gonic/gin" ) @@ -12,22 +13,26 @@ import ( var embeddedFiles embed.FS type Handler struct { + ServeFrontend bool } -func NewHandler() *Handler { - return &Handler{} +func NewHandler(config *config.Config) *Handler { + return &Handler{ + ServeFrontend: config.Server.ServeFrontend, + } } func Routes(router *gin.Engine, h *Handler) { - - router.Use(staticMiddleware("dist")) - router.Static("/assets", "dist/assets") - - // Gzip compression middleware - router.Group("/assets").Use(func(c *gin.Context) { - c.Header("Cache-Control", "max-age=31536000, immutable") - c.Next() - }) + if h.ServeFrontend { + router.Use(staticMiddleware("dist")) + router.Static("/assets", "dist/assets") + + // Gzip compression middleware + router.Group("/assets").Use(func(c *gin.Context) { + c.Header("Cache-Control", "max-age=31536000, immutable") + c.Next() + }) + } } |