mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 18:07:01 +00:00
Add a third, simple, example for folder structuring as requested at https://github.com/kataras/iris/issues/748
One change to code base but it will be described at the next version: Error Handlers (`app.OnErrorCode/OnAnyErrorCode`) respect the `app.UseGlobal`'s middlewares now (not the `app.Use` for reasons we can all understand, hopefully). Former-commit-id: ec97bbb04548f9932cf4d7b950be513b70747bcb
This commit is contained in:
@@ -534,6 +534,12 @@ func (api *APIBuilder) Controller(relativePath string, controller activator.Base
|
||||
api.reporter.Add("%v for path: '%s'", err, relativePath)
|
||||
}
|
||||
|
||||
if cInit, ok := controller.(interface {
|
||||
Init(activator.RegisterFunc)
|
||||
}); ok {
|
||||
cInit.Init(registerFunc)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -800,6 +806,10 @@ func (api *APIBuilder) StaticWeb(requestPath string, systemPath string) *Route {
|
||||
// and/or disable the gzip if gzip response recorder
|
||||
// was active.
|
||||
func (api *APIBuilder) OnErrorCode(statusCode int, handlers ...context.Handler) {
|
||||
if len(api.beginGlobalHandlers) > 0 {
|
||||
handlers = joinHandlers(api.beginGlobalHandlers, handlers)
|
||||
}
|
||||
|
||||
api.errorCodeHandlers.Register(statusCode, handlers...)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user