aboutsummaryrefslogtreecommitdiffstats
path: root/frontend
diff options
context:
space:
mode:
authorLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-07-24 01:07:11 -0400
committerLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-07-24 01:07:11 -0400
commita88946bb7fcfc1632661eafc84eac0aa1c2573c3 (patch)
tree4e39423ed3feb3d50fa5178b2aef6a3a4e3881a8 /frontend
parent5cfb906a4f4d9242b69c85c33f3e350f95820ed2 (diff)
downloaddonetick-a88946bb7fcfc1632661eafc84eac0aa1c2573c3.tar.gz
donetick-a88946bb7fcfc1632661eafc84eac0aa1c2573c3.tar.bz2
donetick-a88946bb7fcfc1632661eafc84eac0aa1c2573c3.zip
Update server configuration to disable serving frontend
Diffstat (limited to 'frontend')
-rw-r--r--frontend/handler.go27
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()
+ })
+ }
}