Package io.micronaut.http.filter
Interface FilterContinuation<R>
- Type Parameters:
R
- The type to return inproceed()
public interface FilterContinuation<R>
A filter continuation gives can be declared as a parameter on a
A continuation can either return the value immediately (e.g.
filter method
. The filter method gets
"delayed" access to the parameter it is requesting. For example, a request filter can declare a
continuation that returns the response. When the filter calls the continuation, other downstream
filters and the final request call will be executed. The continuation will return once the
response has been received and processed by downstream filters.A continuation can either return the value immediately (e.g.
FilterContinuation<HttpResponse<?>>
), in which case the call to proceed()
will
block, or it can return a reactive wrapper (e.g.
FilterContinuation<Publisher<HttpResponse<?>>>
). With a reactive wrapper,
proceed()
will not block, and downstream processing will happen asynchronously (after
the reactive stream is subscribed to).-
Method Summary
Modifier and TypeMethodDescriptionproceed()
Proceed processing downstream of this filter.request
(@NonNull HttpRequest<?> request) Update the request for downstream processing.
-
Method Details
-
request
Update the request for downstream processing.- Parameters:
request
- The new request- Returns:
- This continuation, for call chaining
-
proceed
Proceed processing downstream of this filter. IfFilterContinuation
is not a reactive type, this method will block until downstream processing completes, and may throw an exception if there is a failure. Blocking netty event loop threads can lead to bugs, so any filter that may block in the netty HTTP server should useExecuteOn
to avoid running on the event loop.
IfFilterContinuation
is a reactive type, this method will return immediately. Downstream processing will happen when the reactive stream is subscribed to, and the reactive stream will produce the downstream result when available.- Returns:
- The downstream result, or reactive stream wrapper thereof
-