mirror of
https://github.com/Kugelschieber/migo.git
synced 2026-01-18 06:40:29 +00:00
Fixed serving admin frontend.
This commit is contained in:
17
cmd/main.go
17
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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user