fix error reponses (#187)

Reviewed-on: https://git.ptzo.gdn/feditools/relay/pulls/187
Co-authored-by: Tyr Mactire <tyr@pettingzoo.co>
Co-committed-by: Tyr Mactire <tyr@pettingzoo.co>
This commit is contained in:
Tyr Mactire 2023-03-22 22:48:45 +00:00 committed by PettingZoo Gitea
parent 83b3d41008
commit 508a0351af
No known key found for this signature in database
GPG Key ID: 39788A4390A1372F

View File

@ -74,6 +74,8 @@ func (s *Server) methodNotAllowedHandler() http.Handler {
// wrap in middleware since middlware isn't run on error pages
return s.WrapInMiddlewares(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", libhttp.MimeTextPlain.String())
w.WriteHeader(http.StatusMethodNotAllowed)
w.Write([]byte(fmt.Sprintf("%d %s", http.StatusMethodNotAllowed, http.StatusText(http.StatusMethodNotAllowed))))
}))
}
@ -82,6 +84,8 @@ func (s *Server) notFoundHandler() http.Handler {
// wrap in middleware since middlware isn't run on error pages
return s.WrapInMiddlewares(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", libhttp.MimeTextPlain.String())
w.WriteHeader(http.StatusNotFound)
w.Write([]byte(fmt.Sprintf("%d %s", http.StatusNotFound, http.StatusText(http.StatusNotFound))))
}))
}