from testdata to public for .html
parent
fd7dcafd4e
commit
727b4fdea6
|
|
@ -17,17 +17,17 @@ import (
|
|||
_ "embed"
|
||||
)
|
||||
|
||||
//go:embed testdata/index.tmpl
|
||||
//go:embed public/index.tmpl
|
||||
var embeddedIndexTMPL string
|
||||
|
||||
//go:embed testdata/*
|
||||
//go:embed public/*
|
||||
var embeddedDir embed.FS
|
||||
|
||||
var dir = func() string {
|
||||
if v := os.Getenv("UI_D"); 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 {
|
||||
|
|
@ -37,7 +37,7 @@ func (h Handler) ui(w http.ResponseWriter, r *http.Request) error {
|
|||
|
||||
w.Header().Set("Cache-Control", "max-age=2592000")
|
||||
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)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue