Annotation Interface RequestFilter


Method annotation for a request filter. A request filter is called before the request is sent out. Possible parameter types are:
  • HttpRequest or MutableHttpRequest, to access the request
  • FilterContinuation<HttpResponse>, FilterContinuation<Publisher<HttpResponse>>. A call to the continuation (and, for the reactive variant, subscribing to the Publisher) 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 with ExecuteOn
  • A @Header, @QueryValue or @CookieValue parameter
  • A @Body parameter of type byte[], String or ByteBuffer. 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.
The return value may be:
  • void or null 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
  • A CompletionStage.
  • A CompletableFuture. Suppose you must write a filter that proceeds with the request in some scenarios. You can use CompletableFuture<@ Nullable HttpResponse<?>> as the return type. Then, to proceed with the request, return CompletableFuture.completedFuture(null).
Since:
4.0.0
Author:
Jonas Konrad
  • Field Details

  • 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

      @AliasFor(member="value") String[] patterns
      Same as value().
      Returns:
      The patterns
      Default:
      {}
    • methods

      HttpMethod[] methods
      Returns:
      The methods to match. Defaults to all
      Default:
      {}