nicer 400 error page

This commit is contained in:
mutantmonkey 2015-10-12 01:03:02 -07:00
parent a7ae455ac1
commit 0a1aa869e4
3 changed files with 11 additions and 2 deletions

View File

@ -86,7 +86,10 @@ func oopsHandler(c web.C, w http.ResponseWriter, r *http.Request, rt RespType, m
func badRequestHandler(c web.C, w http.ResponseWriter, r *http.Request) { func badRequestHandler(c web.C, w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest) err := Templates["400.html"].ExecuteWriter(pongo2.Context{}, w)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
} }
func unauthorizedHandler(c web.C, w http.ResponseWriter, r *http.Request) { func unauthorizedHandler(c web.C, w http.ResponseWriter, r *http.Request) {

View File

@ -45,8 +45,9 @@ func populateTemplatesMap(tSet *pongo2.TemplateSet, tMap map[string]*pongo2.Temp
"index.html", "index.html",
"paste.html", "paste.html",
"API.html", "API.html",
"404.html", "400.html",
"401.html", "401.html",
"404.html",
"oops.html", "oops.html",
"display/audio.html", "display/audio.html",

5
templates/400.html Normal file
View File

@ -0,0 +1,5 @@
{% extends "base.html" %}
{% block content %}
400 Bad Request
{% endblock %}