Fix subdir static/

This commit is contained in:
Jan Bader 2021-11-07 22:04:22 +00:00
parent a891047b7a
commit 30b306e485
2 changed files with 7 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package http package http
import ( import (
"io/fs"
"net/http" "net/http"
"time" "time"
@ -31,7 +32,11 @@ func (h *Handler) Serve() {
templ := template.Must(template.New("").Funcs(router.FuncMap).ParseFS(web.Templates, "*")) templ := template.Must(template.New("").Funcs(router.FuncMap).ParseFS(web.Templates, "*"))
router.SetHTMLTemplate(templ) 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("/", func(c *gin.Context) { c.HTML(http.StatusOK, "index", nil) })
router.GET("/login", h.login) router.GET("/login", h.login)

View File

@ -5,5 +5,5 @@ import "embed"
//go:embed *.html //go:embed *.html
var Templates embed.FS var Templates embed.FS
//go:embed static/* //go:embed static
var Static embed.FS var Static embed.FS