Interface Filter

All Superinterfaces:
All Known Implementing Classes:
AddSecretFilter, AddSeleniumUserAgent, AddWebDriverSpecHeaders, BasicAuthenticationFilter, CheckContentTypeHeader, CheckOriginHeader, DumpHttpExchangeFilter, EnsureSpecCompliantHeaders, EnsureSpecCompliantResponseHeaders, ErrorFilter, RequiresSecretFilter, RetryRequest, SpanDecorator
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Filter extends Function<HttpHandler,HttpHandler>
Can be wrapped around an HttpHandler in order to either modify incoming HttpRequests or outgoing HttpResponses using the well-known "Filter" pattern. This is very similar to the Servlet spec's javax.servlet.Filter, but takes advantage of lambdas:

 Filter filter = next -> {
   return req -> {
     req.addHeader("cheese", "brie");
     HttpResponse res = next.apply(req);
     res.addHeader("vegetable", "peas");
     return res;

Because each filter returns an HttpHandler, it's easy to do processing before, or after each request, as well as short-circuit things if necessary.