Handle internal server error using new custom template

This commit is contained in:
2024-05-14 11:35:15 +07:00
parent 420140918c
commit 43e16f1d79
17 changed files with 74 additions and 60 deletions

View File

@ -25,20 +25,24 @@ type wrapper struct {
}
func (w *wrapper) WriteHeader(code int) {
switch code {
case http.StatusNotFound:
w.statusCode = code
if code == http.StatusNotFound {
w.Header().Set("Content-Type", "text/html")
w.ResponseWriter.WriteHeader(code)
errorHandler.NotFound(w.ResponseWriter, w.request)
return
case http.StatusInternalServerError:
}
if code == http.StatusInternalServerError {
w.Header().Set("Content-Type", "text/html")
w.ResponseWriter.WriteHeader(code)
errorHandler.InternalServerError(w.ResponseWriter, w.request)
return
default:
w.ResponseWriter.WriteHeader(code)
w.statusCode = code
return
}
w.ResponseWriter.WriteHeader(code)
return
}
func Handler(next http.Handler) http.Handler {