diff --git a/cert/web.go b/cert/web.go index e947ad9..ea931c3 100644 --- a/cert/web.go +++ b/cert/web.go @@ -4,6 +4,7 @@ package cert // This file provides the web app and registers itself via init(). import ( + "embed" "html/template" "net/http" "strings" @@ -11,9 +12,12 @@ import ( "github.com/linuxexam/goweb/router" ) +//embed resource files +//go:embed *.html +var webUI embed.FS + var ( - tpls = template.Must(template.ParseFiles( - "cert/cert.html")) + tpls = template.Must(template.ParseFS(webUI, "*.html")) ) type PageCert struct { diff --git a/router/router.go b/router/router.go index 0d8e6dc..3744b7f 100644 --- a/router/router.go +++ b/router/router.go @@ -1,14 +1,17 @@ package router import ( + "embed" "html/template" "net/http" "sync" ) +//go:embed router.html +var webUI embed.FS + var ( - tpls = template.Must(template.ParseFiles( - "router/router.html")) + tpls = template.Must(template.ParseFS(webUI, "*.html")) ) var ( appsMu sync.RWMutex