1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-11 09:10:40 +00:00

beego.Context.Abort return immediately

* add common 4XX/5XX HTTP exceptions
This commit is contained in:
Pengfei Xue
2013-11-26 08:46:46 +08:00
parent c7a0298546
commit 76c0636125
3 changed files with 62 additions and 17 deletions

View File

@ -2,6 +2,8 @@ package context
import (
"net/http"
"github.com/astaxie/beego/middleware"
)
type Context struct {
@ -19,6 +21,13 @@ func (ctx *Context) Redirect(status int, localurl string) {
func (ctx *Context) Abort(status int, body string) {
ctx.Output.SetStatus(status)
ctx.Output.Body([]byte(body))
if e, ok := middleware.HTTPExceptionMaps[status]; ok {
if len(body) >= 1 {
e.Description = body
}
panic(e)
}
}
func (ctx *Context) WriteString(content string) {