From 30b306e48567bddf7eb81ee821b3218204350ad6 Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Sun, 7 Nov 2021 22:04:22 +0000 Subject: [PATCH] Fix subdir static/ --- http/http.go | 7 ++++++- web/templates.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/http/http.go b/http/http.go index 00ef24a..f04eebe 100644 --- a/http/http.go +++ b/http/http.go @@ -1,6 +1,7 @@ package http import ( + "io/fs" "net/http" "time" @@ -31,7 +32,11 @@ func (h *Handler) Serve() { templ := template.Must(template.New("").Funcs(router.FuncMap).ParseFS(web.Templates, "*")) router.SetHTMLTemplate(templ) - router.StaticFS("/static", http.FS(web.Static)) + static, err := fs.Sub(web.Static, "static") + if err != nil { + panic("couldn't open static files") + } + router.StaticFS("/static", http.FS(static)) router.GET("/", func(c *gin.Context) { c.HTML(http.StatusOK, "index", nil) }) router.GET("/login", h.login) diff --git a/web/templates.go b/web/templates.go index c3db7a7..67db5e9 100644 --- a/web/templates.go +++ b/web/templates.go @@ -5,5 +5,5 @@ import "embed" //go:embed *.html var Templates embed.FS -//go:embed static/* +//go:embed static var Static embed.FS