Package io.micronaut.http.annotation
Annotation Interface RequestFilter
@Documented
@Retention(RUNTIME)
@Target(METHOD)
@Inherited
@Executable
public @interface RequestFilter
Method annotation for a request filter. A request filter is called before the request is sent
out. Possible parameter types are:
HttpRequest
orMutableHttpRequest
, to access the requestFilterContinuation
<HttpResponse
>,FilterContinuation
<Publisher
<HttpResponse
>>. A call to the continuation (and, for the reactive variant, subscribing to thePublisher
) will trigger execution of downstream filters, and finally perform the request. The response returned by the continuation will be the response produced by the downstream, and can be modified and returned. Note that if you call a non-reactive continuation, the call will block, which may block the netty event loop. For that reason, always mark such a filter withExecuteOn
- A
@
Header
,@
QueryValue
or@
CookieValue
parameter - A
@
Body
parameter of typebyte[]
,String
orByteBuffer
. Only supported for some HTTP server implementations. - A
MutablePropagatedContext
to modify the propagated context - A RouteMatch of the route that will handle this request. Note: Unless the parameter is
marked as
Nullable
, the filter method will not match for requests that do not match a route (e.g. static resources). This parameter is only supported on the server.
void
ornull
to immediately continue execution, without changing the request or response- An updated
HttpRequest
- A
HttpResponse
to skip execution of the request - A
Publisher
(or other reactive type) that produces any of these return types, to delay further execution
- Since:
- 4.0.0
- Author:
- Jonas Konrad
-
Field Details
-
MATCH_ALL_PATTERN
Pattern used to match all requests.- See Also:
-
-
Element Details
-
value
String[] value- Returns:
- The patterns this filter should match
- Default:
- {}
-
patternStyle
FilterPatternStyle patternStyle- Returns:
- The style of pattern this filter uses
- Default:
- ANT
-
patterns
Same asvalue()
.- Returns:
- The patterns
- Default:
- {}
-
methods
HttpMethod[] methods- Returns:
- The methods to match. Defaults to all
- Default:
- {}
-