not found
This commit is contained in:
parent
9c2a1c3b97
commit
1387a2938e
|
@ -83,7 +83,7 @@ func StartServer(world *model.DfWorld, static embed.FS) {
|
||||||
|
|
||||||
srv.router.PathPrefix("/load").Handler(srv.loader)
|
srv.router.PathPrefix("/load").Handler(srv.loader)
|
||||||
|
|
||||||
spa := spaHandler{staticFS: static, staticPath: "static", indexPath: "index.html"}
|
spa := spaHandler{server: srv, staticFS: static, staticPath: "static", indexPath: "index.html"}
|
||||||
srv.router.PathPrefix("/").Handler(spa)
|
srv.router.PathPrefix("/").Handler(spa)
|
||||||
|
|
||||||
OpenBrowser("http://localhost:8080")
|
OpenBrowser("http://localhost:8080")
|
||||||
|
@ -93,6 +93,7 @@ func StartServer(world *model.DfWorld, static embed.FS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type spaHandler struct {
|
type spaHandler struct {
|
||||||
|
server *DfServer
|
||||||
staticFS embed.FS
|
staticFS embed.FS
|
||||||
staticPath string
|
staticPath string
|
||||||
indexPath string
|
indexPath string
|
||||||
|
@ -115,7 +116,10 @@ func (h spaHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Println(path)
|
fmt.Println(path)
|
||||||
index, err := h.staticFS.ReadFile(h.staticPath + "/" + h.indexPath)
|
index, err := h.staticFS.ReadFile(h.staticPath + "/" + h.indexPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
err = h.server.templates.Render(w, "notFound.html", nil)
|
||||||
|
if err != nil {
|
||||||
|
httpError(w, err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
{{template "layout.html" .}}
|
||||||
|
|
||||||
|
{{define "title"}}Not Found{{end}}
|
||||||
|
|
||||||
|
{{define "content"}}
|
||||||
|
|
||||||
|
Not found
|
||||||
|
|
||||||
|
{{- end }}
|
Loading…
Reference in New Issue