Skip to content

Commit

Permalink
Embed public files
Browse files Browse the repository at this point in the history
  • Loading branch information
aceberg committed Dec 18, 2023
1 parent a3a774b commit 99a6176
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions internal/web/const-var.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ var (
//
//go:embed templates/*
var templFS embed.FS

// pubFS - public folder
//
//go:embed public/*
var pubFS embed.FS
6 changes: 3 additions & 3 deletions internal/web/webgui.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package web
import (
"html/template"
"log"
// "net/http"
"net/http"

"github.com/gin-gonic/gin"

Expand Down Expand Up @@ -39,11 +39,11 @@ func Gui(dirPath, nodePath string) {

gin.SetMode(gin.ReleaseMode)
router := gin.Default()
// router.LoadHTMLGlob(TemplPath + "/*.html")

templ := template.Must(template.New("").ParseFS(templFS, "templates/*"))
router.SetHTMLTemplate(templ)

router.Static("/public/", "../../internal/web/public")
router.StaticFS("/public", http.FS(pubFS))

router.GET("/", indexHandler) // index.go
router.GET("/config/", configHandler) // config.go
Expand Down

0 comments on commit 99a6176

Please sign in to comment.