Fixed serving admin frontend.

This commit is contained in:
2023-07-18 23:45:59 +02:00
parent b5860b4f64
commit 6c47cf18b4

View File

@@ -11,6 +11,7 @@ import (
"net/http" "net/http"
"os" "os"
"os/signal" "os/signal"
"path/filepath"
"time" "time"
) )
@@ -52,17 +53,11 @@ func main() {
http.ServeFile(w, r, "cmd/admin/dist/index.html") http.ServeFile(w, r, "cmd/admin/dist/index.html")
}) })
} else { } else {
r.Handle("/assets/*", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fs := http.FileServer(http.FS(assets))
// TODO http.StripPrefix("/admin/assets/", r.Handle("/assets/*", http.StripPrefix("/admin/assets/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
log.Println(r.URL.Path) r.URL.Path = filepath.Join("admin/dist/assets", r.URL.Path)
d, err := assets.ReadFile("admin/dist/assets/index-e8823577.css") fs.ServeHTTP(w, r)
})))
if err != nil {
log.Println(err)
}
w.Write(d)
}))
r.Get("/favicon.ico", func(w http.ResponseWriter, r *http.Request) { r.Get("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "image/x-icon") w.Header().Set("Content-Type", "image/x-icon")