fix the cycle import
Showing
2 changed files
with
12 additions
and
13 deletions
| ... | @@ -31,7 +31,6 @@ import ( | ... | @@ -31,7 +31,6 @@ import ( |
| 31 | "strings" | 31 | "strings" |
| 32 | "time" | 32 | "time" |
| 33 | 33 | ||
| 34 | "github.com/astaxie/beego" | ||
| 35 | "github.com/astaxie/beego/utils" | 34 | "github.com/astaxie/beego/utils" |
| 36 | ) | 35 | ) |
| 37 | 36 | ||
| ... | @@ -56,13 +55,7 @@ func (ctx *Context) Redirect(status int, localurl string) { | ... | @@ -56,13 +55,7 @@ func (ctx *Context) Redirect(status int, localurl string) { |
| 56 | // if beego.ErrorMaps exists, panic body. | 55 | // if beego.ErrorMaps exists, panic body. |
| 57 | func (ctx *Context) Abort(status int, body string) { | 56 | func (ctx *Context) Abort(status int, body string) { |
| 58 | ctx.ResponseWriter.WriteHeader(status) | 57 | ctx.ResponseWriter.WriteHeader(status) |
| 59 | // first panic from ErrorMaps, is is user defined error functions. | 58 | panic(body) |
| 60 | if _, ok := beego.ErrorMaps[body]; ok { | ||
| 61 | panic(body) | ||
| 62 | } | ||
| 63 | // last panic user string | ||
| 64 | ctx.ResponseWriter.Write([]byte(body)) | ||
| 65 | panic(beego.USERSTOPRUN) | ||
| 66 | } | 59 | } |
| 67 | 60 | ||
| 68 | // Write string to response body. | 61 | // Write string to response body. | ... | ... |
| ... | @@ -270,16 +270,22 @@ func (c *Controller) Redirect(url string, code int) { | ... | @@ -270,16 +270,22 @@ func (c *Controller) Redirect(url string, code int) { |
| 270 | // Aborts stops controller handler and show the error data if code is defined in ErrorMap or code string. | 270 | // Aborts stops controller handler and show the error data if code is defined in ErrorMap or code string. |
| 271 | func (c *Controller) Abort(code string) { | 271 | func (c *Controller) Abort(code string) { |
| 272 | status, err := strconv.Atoi(code) | 272 | status, err := strconv.Atoi(code) |
| 273 | if err == nil { | 273 | if err != nil { |
| 274 | c.Ctx.Abort(status, code) | 274 | status = 200 |
| 275 | } else { | ||
| 276 | c.Ctx.Abort(200, code) | ||
| 277 | } | 275 | } |
| 276 | c.CustomAbort(status, code) | ||
| 278 | } | 277 | } |
| 279 | 278 | ||
| 280 | // CustomAbort stops controller handler and show the error data, it's similar Aborts, but support status code and body. | 279 | // CustomAbort stops controller handler and show the error data, it's similar Aborts, but support status code and body. |
| 281 | func (c *Controller) CustomAbort(status int, body string) { | 280 | func (c *Controller) CustomAbort(status int, body string) { |
| 282 | c.Ctx.Abort(status, body) | 281 | c.Ctx.ResponseWriter.WriteHeader(status) |
| 282 | // first panic from ErrorMaps, is is user defined error functions. | ||
| 283 | if _, ok := ErrorMaps[body]; ok { | ||
| 284 | panic(body) | ||
| 285 | } | ||
| 286 | // last panic user string | ||
| 287 | c.Ctx.ResponseWriter.Write([]byte(body)) | ||
| 288 | panic(USERSTOPRUN) | ||
| 283 | } | 289 | } |
| 284 | 290 | ||
| 285 | // StopRun makes panic of USERSTOPRUN error and go to recover function if defined. | 291 | // StopRun makes panic of USERSTOPRUN error and go to recover function if defined. | ... | ... |
-
Please register or sign in to post a comment