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"
|
"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")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user