mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 12:00:55 +00:00
fix the cycle import
This commit is contained in:
parent
6e9d2dc965
commit
e938876c4a
@ -31,7 +31,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/astaxie/beego"
|
|
||||||
"github.com/astaxie/beego/utils"
|
"github.com/astaxie/beego/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -56,13 +55,7 @@ func (ctx *Context) Redirect(status int, localurl string) {
|
|||||||
// if beego.ErrorMaps exists, panic body.
|
// if beego.ErrorMaps exists, panic body.
|
||||||
func (ctx *Context) Abort(status int, body string) {
|
func (ctx *Context) Abort(status int, body string) {
|
||||||
ctx.ResponseWriter.WriteHeader(status)
|
ctx.ResponseWriter.WriteHeader(status)
|
||||||
// first panic from ErrorMaps, is is user defined error functions.
|
panic(body)
|
||||||
if _, ok := beego.ErrorMaps[body]; ok {
|
|
||||||
panic(body)
|
|
||||||
}
|
|
||||||
// last panic user string
|
|
||||||
ctx.ResponseWriter.Write([]byte(body))
|
|
||||||
panic(beego.USERSTOPRUN)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write string to response body.
|
// Write string to response body.
|
||||||
|
@ -270,16 +270,22 @@ func (c *Controller) Redirect(url string, code int) {
|
|||||||
// Aborts stops controller handler and show the error data if code is defined in ErrorMap or code string.
|
// Aborts stops controller handler and show the error data if code is defined in ErrorMap or code string.
|
||||||
func (c *Controller) Abort(code string) {
|
func (c *Controller) Abort(code string) {
|
||||||
status, err := strconv.Atoi(code)
|
status, err := strconv.Atoi(code)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
c.Ctx.Abort(status, code)
|
status = 200
|
||||||
} else {
|
|
||||||
c.Ctx.Abort(200, code)
|
|
||||||
}
|
}
|
||||||
|
c.CustomAbort(status, code)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CustomAbort stops controller handler and show the error data, it's similar Aborts, but support status code and body.
|
// CustomAbort stops controller handler and show the error data, it's similar Aborts, but support status code and body.
|
||||||
func (c *Controller) CustomAbort(status int, body string) {
|
func (c *Controller) CustomAbort(status int, body string) {
|
||||||
c.Ctx.Abort(status, body)
|
c.Ctx.ResponseWriter.WriteHeader(status)
|
||||||
|
// first panic from ErrorMaps, is is user defined error functions.
|
||||||
|
if _, ok := ErrorMaps[body]; ok {
|
||||||
|
panic(body)
|
||||||
|
}
|
||||||
|
// last panic user string
|
||||||
|
c.Ctx.ResponseWriter.Write([]byte(body))
|
||||||
|
panic(USERSTOPRUN)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StopRun makes panic of USERSTOPRUN error and go to recover function if defined.
|
// StopRun makes panic of USERSTOPRUN error and go to recover function if defined.
|
||||||
|
Loading…
Reference in New Issue
Block a user