1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 18:07:01 +00:00

fix https://github.com/kataras/iris/issues/1450 and continue on implementing 1449

Former-commit-id: 617f64d061e88f050a443ea1751fa244164656c5
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-02-14 23:34:56 +02:00
parent 09a410c6cb
commit c13fd84354
24 changed files with 581 additions and 144 deletions

View File

@@ -48,13 +48,14 @@ type Application struct {
Router router.Party
Controllers []*ControllerActivator
websocketControllers []websocket.ConnHandler
ErrorHandler hero.ErrorHandler
ErrorHandler di.ErrorHandler
}
func newApp(subRouter router.Party, values di.Values) *Application {
return &Application{
Router: subRouter,
Dependencies: values,
ErrorHandler: di.DefaultErrorHandler,
}
}
@@ -211,7 +212,7 @@ func makeInjector(injector *di.StructInjector) websocket.StructInjector {
return func(_ reflect.Type, nsConn *websocket.NSConn) reflect.Value {
v := injector.Acquire()
if injector.CanInject {
injector.InjectElem(v.Elem(), reflect.ValueOf(websocket.GetContext(nsConn.Conn)))
injector.InjectElem(websocket.GetContext(nsConn.Conn), v.Elem())
}
return v
}
@@ -258,8 +259,8 @@ func (app *Application) handle(controller interface{}) *ControllerActivator {
// HandleError registers a `hero.ErrorHandlerFunc` which will be fired when
// application's controllers' functions returns an non-nil error.
// Each controller can override it by implementing the `hero.ErrorHandler`.
func (app *Application) HandleError(errHandler hero.ErrorHandlerFunc) *Application {
app.ErrorHandler = errHandler
func (app *Application) HandleError(errorHandler func(ctx context.Context, err error)) *Application {
app.ErrorHandler = di.ErrorHandlerFunc(errorHandler)
return app
}