from testdata to public for .html

main
bel 2025-11-30 08:40:15 -07:00
parent fd7dcafd4e
commit 727b4fdea6
3 changed files with 4 additions and 4 deletions

View File

@ -17,17 +17,17 @@ import (
_ "embed" _ "embed"
) )
//go:embed testdata/index.tmpl //go:embed public/index.tmpl
var embeddedIndexTMPL string var embeddedIndexTMPL string
//go:embed testdata/* //go:embed public/*
var embeddedDir embed.FS var embeddedDir embed.FS
var dir = func() string { var dir = func() string {
if v := os.Getenv("UI_D"); v != "" { if v := os.Getenv("UI_D"); v != "" {
return v return v
} }
return "./src/cmd/server/handler/testdata" return "./src/cmd/server/handler/public"
}() }()
func (h Handler) ui(w http.ResponseWriter, r *http.Request) error { func (h Handler) ui(w http.ResponseWriter, r *http.Request) error {
@ -37,7 +37,7 @@ func (h Handler) ui(w http.ResponseWriter, r *http.Request) error {
w.Header().Set("Cache-Control", "max-age=2592000") w.Header().Set("Cache-Control", "max-age=2592000")
fs := http.FileServer(http.FS(embeddedDir)) fs := http.FileServer(http.FS(embeddedDir))
r.URL.Path = fmt.Sprintf("/testdata/%s", strings.TrimPrefix(r.URL.Path, "/experimental/ui")) r.URL.Path = fmt.Sprintf("/public/%s", strings.TrimPrefix(r.URL.Path, "/experimental/ui"))
fs.ServeHTTP(w, r) fs.ServeHTTP(w, r)
return nil return nil
} }