From fa81548e8a74e39679e5e11ea31d0d6ccc854425 Mon Sep 17 00:00:00 2001 From: Damillora Date: Sun, 23 Feb 2025 19:56:39 +0000 Subject: [PATCH] feat: fully complete SPA embedding --- pkg/app/app.go | 7 ++++--- pkg/app/frontend_routes.go | 13 ------------- pkg/app/routes.go | 2 -- 3 files changed, 4 insertions(+), 18 deletions(-) delete mode 100644 pkg/app/frontend_routes.go diff --git a/pkg/app/app.go b/pkg/app/app.go index 3116878..04f5722 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -34,11 +34,12 @@ func Start() { webFS := web.WebAssets() webAssets, _ := fs.Sub(webFS, "_app") - g.StaticFileFS("/", "./app.html", http.FS(webFS)) - // g.StaticFile("/", "./pkg/web/build/index.html") + g.NoRoute(func(c *gin.Context) { + //c.String(http.StatusOK, "AAA") + c.FileFromFS("./app.html", http.FS(webFS)) + }) g.StaticFS("/_app", http.FS(webAssets)) g.Static("/data", config.CurrentConfig.DataDirectory) - g.Use(cors.Default()) InitializeRoutes(g) diff --git a/pkg/app/frontend_routes.go b/pkg/app/frontend_routes.go deleted file mode 100644 index 4672f9b..0000000 --- a/pkg/app/frontend_routes.go +++ /dev/null @@ -1,13 +0,0 @@ -package app - -import ( - "github.com/gin-gonic/gin" -) - -func InitializeFrontendRoutes(g *gin.Engine) { - g.NoRoute(frontendHome) -} - -func frontendHome(c *gin.Context) { - c.File("./web/static/index.html") -} diff --git a/pkg/app/routes.go b/pkg/app/routes.go index 1440abb..ac5365b 100644 --- a/pkg/app/routes.go +++ b/pkg/app/routes.go @@ -11,6 +11,4 @@ func InitializeRoutes(g *gin.Engine) { InitializeTagRoutes(g) InitializeBlobRoutes(g) InitializePostRoutes(g) - - InitializeFrontendRoutes(g) }