1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-22 16:00:50 +00:00

fix: add error code support

This commit is contained in:
Chenrui 2020-07-08 18:09:01 +08:00
parent 946a42c021
commit 03f78b2e4a
No known key found for this signature in database
GPG Key ID: E6C6812B87229952
2 changed files with 15 additions and 1 deletions

View File

@ -28,7 +28,7 @@ import (
)
const (
errorTypeHandler = iota
errorTypeHandler = iota
errorTypeController
)
@ -359,6 +359,19 @@ func gatewayTimeout(rw http.ResponseWriter, r *http.Request) {
)
}
// show 413 Payload Too Large
func payloadTooLarge(rw http.ResponseWriter, r *http.Request) {
responseError(rw, r,
413,
"<br>The page you have requested is unavailable."+
"<br>Perhaps you are here because:"+
"<br><br><ul>"+
"<br>The request entity is larger than limits defined by server"+
"<br>Please change the request entity and try again."+
"</ul>",
)
}
func responseError(rw http.ResponseWriter, r *http.Request, errCode int, errContent string) {
t, _ := template.New("beegoerrortemp").Parse(errtpl)
data := M{

View File

@ -34,6 +34,7 @@ func registerDefaultErrorHandler() error {
"504": gatewayTimeout,
"417": invalidxsrf,
"422": missingxsrf,
"413": payloadTooLarge,
}
for e, h := range m {
if _, ok := ErrorMaps[e]; !ok {