mirror of
https://github.com/kataras/iris.git
synced 2026-01-08 04:21:57 +00:00
🚀 add Party.OnErrorFunc, UseFunc and DoneFunc to be aligned with the new HandleFunc
Former-commit-id: 381ce0f86f376ef7652b5e918474f9e37b391781
This commit is contained in:
@@ -57,10 +57,15 @@ type Party interface {
|
||||
// Use appends Handler(s) to the current Party's routes and child routes.
|
||||
// If the current Party is the root, then it registers the middleware to all child Parties' routes too.
|
||||
Use(middleware ...context.Handler)
|
||||
|
||||
// UseFunc same as "Use" but it accepts dynamic functions as its "handlersFn" input.
|
||||
// See `OnErrorFunc`, `RegisterDependency`, `DoneFunc` and `HandleFunc` for more.
|
||||
UseFunc(handlersFn ...interface{})
|
||||
// Done appends to the very end, Handler(s) to the current Party's routes and child routes.
|
||||
// The difference from .Use is that this/or these Handler(s) are being always running last.
|
||||
Done(handlers ...context.Handler)
|
||||
// DoneFunc same as "Done" but it accepts dynamic functions as its "handlersFn" input.
|
||||
// See `OnErrorFunc`, `RegisterDependency`, `UseFunc` and `HandleFunc` for more.
|
||||
DoneFunc(handlersFn ...interface{})
|
||||
// Reset removes all the begin and done handlers that may derived from the parent party via `Use` & `Done`,
|
||||
// and the execution rules.
|
||||
// Note that the `Reset` will not reset the handlers that are registered via `UseGlobal` & `DoneGlobal`.
|
||||
@@ -106,8 +111,17 @@ type Party interface {
|
||||
// GetContainer returns the DI Container of this Party.
|
||||
// Use it to manually convert functions or structs(controllers) to a Handler.
|
||||
//
|
||||
// See `RegisterDependency` and `HandleFunc` too.
|
||||
// See `OnErrorFunc`, `RegisterDependency`, `UseFunc`, `DoneFunc` and `HandleFunc` too.
|
||||
GetContainer() *hero.Container
|
||||
// OnErrorFunc adds an error handler for this Party's DI Hero Container and its handlers (or controllers).
|
||||
// The "errorHandler" handles any error may occurred and returned
|
||||
// during dependencies injection of the Party's hero handlers or from the handlers themselves.
|
||||
//
|
||||
// Same as:
|
||||
// GetContainer().GetErrorHandler = func(ctx iris.Context) hero.ErrorHandler { return errorHandler }
|
||||
//
|
||||
// See `RegisterDependency`, `UseFunc`, `DoneFunc` and `HandleFunc` too.
|
||||
OnErrorFunc(errorHandler func(context.Context, error))
|
||||
// RegisterDependency adds a dependency.
|
||||
// The value can be a single struct value or a function.
|
||||
// Follow the rules:
|
||||
@@ -125,8 +139,10 @@ type Party interface {
|
||||
// - RegisterDependency(loggerService{prefix: "dev"})
|
||||
// - RegisterDependency(func(ctx iris.Context) User {...})
|
||||
// - RegisterDependency(func(User) OtherResponse {...})
|
||||
//
|
||||
// See `OnErrorFunc`, `UseFunc`, `DoneFunc` and `HandleFunc` too.
|
||||
RegisterDependency(dependency interface{}) *hero.Dependency
|
||||
// HandleFunc accepts one or more "handlersFn" functions which each one of them
|
||||
// HandleFunc same as `HandleFunc` but it accepts one or more "handlersFn" functions which each one of them
|
||||
// can accept any input arguments that match with the Party's registered Container's `Dependencies` and
|
||||
// any output result; like custom structs <T>, string, []byte, int, error,
|
||||
// a combination of the above, hero.Result(hero.View | hero.Response) and more.
|
||||
@@ -135,6 +151,8 @@ type Party interface {
|
||||
// the "handlersFn" will call `ctx.Next()` automatically when not called manually.
|
||||
// To stop the execution and not continue to the next "handlersFn"
|
||||
// the end-developer should output an error and return `iris.ErrStopExecution`.
|
||||
//
|
||||
// See `OnErrorFunc`, `RegisterDependency`, `UseFunc` and `DoneFunc` too.
|
||||
HandleFunc(method, relativePath string, handlersFn ...interface{}) *Route
|
||||
|
||||
// Handle registers a route to the server's router.
|
||||
|
||||
Reference in New Issue
Block a user