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

update abort & error show & sessionRelease in defer

This commit is contained in:
astaxie
2013-12-16 22:54:29 +08:00
parent 7fd18ba639
commit f8708d01bf
4 changed files with 31 additions and 200 deletions

View File

@ -16,18 +16,24 @@ type Context struct {
func (ctx *Context) Redirect(status int, localurl string) {
ctx.Output.Header("Location", localurl)
ctx.Output.SetStatus(status)
ctx.Output.Body([]byte(" "))
}
func (ctx *Context) Abort(status int, body string) {
ctx.Output.SetStatus(status)
ctx.Output.Body([]byte(body))
// first panic from ErrorMaps, is is user defined error functions.
if _, ok := middleware.ErrorMaps[body]; ok {
panic(body)
}
// second panic from HTTPExceptionMaps, it is system defined functions.
if e, ok := middleware.HTTPExceptionMaps[status]; ok {
if len(body) >= 1 {
e.Description = body
}
panic(e)
}
// last panic user string
panic(body)
}
func (ctx *Context) WriteString(content string) {