mirror of
https://github.com/infinite-iroha/touka.git
synced 2026-02-03 08:51:11 +08:00
add ErrorUseHandle
This commit is contained in:
parent
484f2f016b
commit
5a10829041
1 changed files with 13 additions and 0 deletions
13
context.go
13
context.go
|
|
@ -437,3 +437,16 @@ func (c *Context) GetReqHeader(key string) string {
|
|||
func (c *Context) GetAllReqHeader() http.Header {
|
||||
return c.Request.Header
|
||||
}
|
||||
|
||||
// 使用定义的errorHandle来处理error并结束当前handle
|
||||
func (c *Context) ErrorUseHandle(code int) {
|
||||
if c.engine != nil && c.engine.errorHandle.handler != nil {
|
||||
c.engine.errorHandle.handler(c, code)
|
||||
c.Abort()
|
||||
return
|
||||
} else {
|
||||
// Default error handling if no custom handler is set
|
||||
c.String(code, http.StatusText(code))
|
||||
c.Abort()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue