Browse Source

nicer 400 error page

pull/59/head
mutantmonkey 9 years ago
parent
commit
0a1aa869e4
  1. 5
      pages.go
  2. 3
      templates.go
  3. 5
      templates/400.html

5
pages.go

@ -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) {

3
templates.go

@ -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

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