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