Skip to content

Commit b360f9b

Browse files
author
Jonathan Zhao
committed
.html files are embedded into the single binary now.
1 parent e7352a3 commit b360f9b

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

cert/web.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@ package cert
44
// This file provides the web app and registers itself via init().
55

66
import (
7+
"embed"
78
"html/template"
89
"net/http"
910
"strings"
1011

1112
"github.com/linuxexam/goweb/router"
1213
)
1314

15+
//embed resource files
16+
//go:embed *.html
17+
var webUI embed.FS
18+
1419
var (
15-
tpls = template.Must(template.ParseFiles(
16-
"cert/cert.html"))
20+
tpls = template.Must(template.ParseFS(webUI, "*.html"))
1721
)
1822

1923
type PageCert struct {

router/router.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
package router
22

33
import (
4+
"embed"
45
"html/template"
56
"net/http"
67
"sync"
78
)
89

10+
//go:embed router.html
11+
var webUI embed.FS
12+
913
var (
10-
tpls = template.Must(template.ParseFiles(
11-
"router/router.html"))
14+
tpls = template.Must(template.ParseFS(webUI, "*.html"))
1215
)
1316
var (
1417
appsMu sync.RWMutex

0 commit comments

Comments
 (0)