use middlewares for notfoundhandler routes

This commit is contained in:
sentriz
2020-01-18 17:44:27 +00:00
parent fa12cb4150
commit 7de773d4c5
4 changed files with 32 additions and 10 deletions

View File

@@ -177,6 +177,9 @@ func (c *Controller) H(h adminHandler) http.Handler {
return
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
if resp.code != 0 {
w.WriteHeader(resp.code)
}
if _, err := buff.WriteTo(w); err != nil {
log.Printf("error writing to response buffer: %v\n", err)
}

View File

@@ -13,7 +13,7 @@ import (
)
func (c *Controller) ServeNotFound(r *http.Request) *Response {
return &Response{template: "not_found.tmpl"}
return &Response{template: "not_found.tmpl", code: 404}
}
func (c *Controller) ServeLogin(r *http.Request) *Response {