func(ctx iris.Context)
. Each middleware is executed when the previous middleware calls the ctx.Next()
method, which can be used for authentication, i.e., if the request isn't authorized to continue, we could throw an error response instead of calling this method.Application.WrapRouter
MethodWrapperFunc
is not an iris.Handler
, instead its signature is: func(http.ResponseWriter, *http.Request, router http.HandlerFunc)
. It's the lowest-level functionality used to intercept requests and optionally change the behaviour of the router (e.g. navigate to another route than the requested path one, perform security checks before even the router is executed and more). A good example of use-case is a CORS implementation.Party.UseRouter
MethodParty.ResetRouteFilters()
or Party.Reset()
is called. They are executed in the order they are registered, and they run before UseGlobal
and Use
on matched routes or UseError
on errors.Application.UseGlobal
MethodOnErrorCode
), in the whole Application (all Parties and Subdomains included.) They are also executed in the order they are registered, and they run before Use
or UseError
.Party.Use
MethodUseGlobal
under a particular Party and its children. They are also executed in the order they are registered, and they run right before the Handle itself (such as Get
, Post
, Patch
, ...) It is not executed on errors.Party.UseError
Method404
or protected 401
resources), unlike Use
. They fire for all children Parties and will be called in the order they were registered.Party.Done
Methodctx.Next
call on the last route's handler, unless Execution Rules are modified.Application.DoneGlobal
MethodUseGlobal
but for the Done
handlers. Runs on the Application instance level, after everything else.http://localhost:8080
, and the output should look exactly like this:http://localhost:8080/a_not_found_resource
:WrapRouter
and UseRouter
are still fired 1st and 2nd, just not shown in the output. Read the block comment to learn why.)OnErrorCode
:OnErrorCode
registered, your UseGlobal
will not be executed.UseRouter
to run everywhere except on the static.example.com
subdomain.static.
one:iris.Context
. This instance is shared across the handlers chain—the Context.Values()
returns temporary memory storage which can be used to transfer data between middleware and handlers.RemoveHandler
method of the *Route
registered by the Handle/Get/Post/Put...
methods. The RemoveHandler
method expects the handler name (it's the PC func, see HandlerName
of the iris context
subpackage) or the handler itself.ExecutionRules
to force Begin(UseXXX) and Finish(DoneXXX) handlers to be executed without the requirement of a ctx.Next()
call, to forcibly forward them:http.Handler/HandlerFunc
net/http
package which is modernized by the Go Authors on each new release of the Go Programming Language.net/http
is compatible with Iris using the iris.FromStd(aThirdPartyMiddleware)
. Remember, ctx.ResponseWriter()
and ctx.Request()
returns the same net/http
input arguments of an http.Handler.Authorization
header on incoming requests and decodes itfunc(ctx iris.Context)
, but it's also compatible with all net/http
middleware forms. See here.