Skip to content

Commit

Permalink
.html files are embedded into the single binary now.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Zhao committed Dec 1, 2021
1 parent e7352a3 commit b360f9b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 6 additions & 2 deletions cert/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ package cert
// This file provides the web app and registers itself via init().

import (
"embed"
"html/template"
"net/http"
"strings"

"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 {
Expand Down
7 changes: 5 additions & 2 deletions router/router.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit b360f9b

Please sign in to comment.