chore: Add 404 page for not found routes

This commit is contained in:
sanjay7178
2024-06-01 10:58:51 +05:30
parent c68d0aad5e
commit ea3f7d1159
3 changed files with 472 additions and 562 deletions

View File

@@ -337,6 +337,11 @@ func main() {
rw.Header().Add("Content-Type", "text/html; charset=utf-8")
web.RenderTemplate(rw, "privacy.tmpl", &web.Page{Title: "Privacy", Build: buildInfo})
})
r.NotFoundHandler = http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
rw.WriteHeader(http.StatusNotFound)
rw.Header().Add("Content-Type", "text/html; charset=utf-8")
web.RenderTemplate(rw, "404.tmpl", &web.Page{Title: "Page not found", Build: buildInfo})
})
secured := r.PathPrefix("/").Subrouter()