This commit is contained in:
bel
2023-10-29 09:21:06 -06:00
parent a623dcc195
commit 227de17951
2 changed files with 22 additions and 6 deletions

View File

@@ -27,10 +27,12 @@ import (
//go:embed public/*
var _staticFileDir embed.FS
var staticFileDir = func() embed.FS {
panic("if dev mode then return live")
return _staticFileDir
}
var publicHandler = func() http.Handler {
if os.Getenv("DEBUG") != "" {
return http.FileServer(http.Dir("./http"))
}
return http.FileServer(http.FS(_staticFileDir))
}()
func Main() {
foo := flag.String("foo", "bal", "bal or reg")
@@ -65,7 +67,7 @@ func Main() {
if *httpOutput != "" {
foo := func(w http.ResponseWriter, r *http.Request) {
if !strings.HasPrefix(r.URL.Path, "/api") {
http.FileServer(http.FS(staticFileDir)).ServeHTTP(w, r)
publicHandler.ServeHTTP(w, r)
return
}