not found
This commit is contained in:
parent
9c2a1c3b97
commit
1387a2938e
2 changed files with 15 additions and 2 deletions
|
@ -83,7 +83,7 @@ func StartServer(world *model.DfWorld, static embed.FS) {
|
|||
|
||||
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)
|
||||
|
||||
OpenBrowser("http://localhost:8080")
|
||||
|
@ -93,6 +93,7 @@ func StartServer(world *model.DfWorld, static embed.FS) {
|
|||
}
|
||||
|
||||
type spaHandler struct {
|
||||
server *DfServer
|
||||
staticFS embed.FS
|
||||
staticPath string
|
||||
indexPath string
|
||||
|
@ -115,7 +116,10 @@ func (h spaHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
fmt.Println(path)
|
||||
index, err := h.staticFS.ReadFile(h.staticPath + "/" + h.indexPath)
|
||||
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
|
||||
}
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
|
|
9
backend/templates/notFound.html
Normal file
9
backend/templates/notFound.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
{{template "layout.html" .}}
|
||||
|
||||
{{define "title"}}Not Found{{end}}
|
||||
|
||||
{{define "content"}}
|
||||
|
||||
Not found
|
||||
|
||||
{{- end }}
|
Loading…
Reference in a new issue