improve (404): 404 errors

This commit is contained in:
Mickael Kerjean
2022-09-14 23:55:11 +10:00
parent 2197385d54
commit e2874f2a9b

View File

@ -70,8 +70,12 @@ func IndexHandler(_path string) func(*App, http.ResponseWriter, *http.Request) {
} }
func NotFoundHandler(ctx *App, res http.ResponseWriter, req *http.Request) { func NotFoundHandler(ctx *App, res http.ResponseWriter, req *http.Request) {
res.WriteHeader(http.StatusNotFound) if strings.Contains(req.Header.Get("accept"), "text/html") {
res.Write(HtmlPage404) res.WriteHeader(http.StatusNotFound)
res.Write(HtmlPage404)
return
}
SendErrorResult(res, ErrNotFound)
} }
func PreflightCorsOK(ctx *App, res http.ResponseWriter, req *http.Request) { func PreflightCorsOK(ctx *App, res http.ResponseWriter, req *http.Request) {