- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A filter used to pre/post-process incoming requests. Pre-processing occurs before the
application's exchange handler is invoked, and post-processing occurs after the exchange handler
returns. Filters are organized in chains, and are associated with
Context instances.
Each HttpFilter in the chain, invokes the next filter within its own filter(Context, FilterChain) implementation. The final HttpFilter in the chain invokes
the applications exchange handler.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceFilter chain that contains all subsequent filters that are configured, as well as the final route. -
Method Summary
Modifier and TypeMethodDescriptionvoidfilter(Context ctx, HttpFilter.FilterChain chain) Asks this filter to pre/post-process the given request.
-
Method Details
-
filter
Asks this filter to pre/post-process the given request. The filter can:- Examine or modify the request headers.
- Set attribute objects in the context, which other filters or the handler can access.
- Decide to either:
- Invoke the next filter in the chain, by calling
HttpFilter.FilterChain.proceed(). - Terminate the chain of invocation, by not calling
HttpFilter.FilterChain.proceed().
- Invoke the next filter in the chain, by calling
- If option 1. above is taken, then when filter() returns all subsequent filters in the Chain have been called, and the response headers can be examined or modified.
- If option 2. above is taken, then this Filter must use the Context to send back an appropriate response.
- Parameters:
ctx- theContextof the current requestchain- theFilterChainwhich allows the next filter to be invoked
-