From 4b08de00b83a0c685a92df1524c351c5ea1f817b Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Sun, 7 Nov 2021 22:01:13 +0000 Subject: [PATCH] Use embedded files --- http/http.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/http/http.go b/http/http.go index ff852e5..00ef24a 100644 --- a/http/http.go +++ b/http/http.go @@ -4,7 +4,10 @@ import ( "net/http" "time" + "html/template" + "git.javil.eu/jacob1123/budgeteer" + "git.javil.eu/jacob1123/budgeteer/web" "github.com/gin-gonic/gin" ) @@ -25,8 +28,10 @@ const ( func (h *Handler) Serve() { router := gin.Default() - router.LoadHTMLGlob("./templates/*") - router.Static("/static", "./static") + templ := template.Must(template.New("").Funcs(router.FuncMap).ParseFS(web.Templates, "*")) + router.SetHTMLTemplate(templ) + + router.StaticFS("/static", http.FS(web.Static)) router.GET("/", func(c *gin.Context) { c.HTML(http.StatusOK, "index", nil) }) router.GET("/login", h.login)