mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 07:40:54 +00:00
fix: add error code support
This commit is contained in:
parent
946a42c021
commit
03f78b2e4a
13
error.go
13
error.go
@ -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) {
|
func responseError(rw http.ResponseWriter, r *http.Request, errCode int, errContent string) {
|
||||||
t, _ := template.New("beegoerrortemp").Parse(errtpl)
|
t, _ := template.New("beegoerrortemp").Parse(errtpl)
|
||||||
data := M{
|
data := M{
|
||||||
|
1
hooks.go
1
hooks.go
@ -34,6 +34,7 @@ func registerDefaultErrorHandler() error {
|
|||||||
"504": gatewayTimeout,
|
"504": gatewayTimeout,
|
||||||
"417": invalidxsrf,
|
"417": invalidxsrf,
|
||||||
"422": missingxsrf,
|
"422": missingxsrf,
|
||||||
|
"413": payloadTooLarge,
|
||||||
}
|
}
|
||||||
for e, h := range m {
|
for e, h := range m {
|
||||||
if _, ok := ErrorMaps[e]; !ok {
|
if _, ok := ErrorMaps[e]; !ok {
|
||||||
|
Loading…
Reference in New Issue
Block a user