mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 02:17:05 +00:00
HandleHTTPError MVC Method as requested at #1595. Read HISTORY.md
example at: https://github.com/kataras/iris/tree/master/_examples/mvc/error-handler-http
This commit is contained in:
@@ -370,7 +370,7 @@ func (api *APIBuilder) SetRegisterRule(rule RouteRegisterRule) Party {
|
||||
return api
|
||||
}
|
||||
|
||||
// Handle registers a route to the server's api.
|
||||
// Handle registers a route to this Party.
|
||||
// if empty method is passed then handler(s) are being registered to all methods, same as .Any.
|
||||
//
|
||||
// Returns a *Route, app will throw any errors later on.
|
||||
@@ -378,6 +378,8 @@ func (api *APIBuilder) Handle(method string, relativePath string, handlers ...co
|
||||
return api.handle(0, method, relativePath, handlers...)
|
||||
}
|
||||
|
||||
// handle registers a full route to this Party.
|
||||
// Use Handle or Get, Post, Put, Delete and et.c. instead.
|
||||
func (api *APIBuilder) handle(errorCode int, method string, relativePath string, handlers ...context.Handler) *Route {
|
||||
routes := api.createRoutes(errorCode, []string{method}, relativePath, handlers...)
|
||||
|
||||
@@ -1242,6 +1244,14 @@ func (api *APIBuilder) OnAnyErrorCode(handlers ...context.Handler) (routes []*Ro
|
||||
routes = append(routes, api.OnErrorCode(statusCode, handlers...)...)
|
||||
}
|
||||
|
||||
if n := len(routes); n > 1 {
|
||||
for _, r := range routes[1:n] {
|
||||
r.NoLog = true
|
||||
}
|
||||
|
||||
routes[0].Title = "ERR"
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user