@Test public void containsHeader() { final RoutingChecker checker = new RoutingChecker(); Routing routing = Routing.builder() .get("/exists", RequestPredicate.create() .containsHeader("my-header") .thenApply((req, resp) -> { checker.handlerInvoked("headerFound"); }).otherwise((req, res) -> { checker.handlerInvoked("headerNotFound"); })) .get("/valid", RequestPredicate.create() .containsHeader("my-header", "abc"::equals) .thenApply((req, resp) -> { checker.handlerInvoked("headerIsValid"); }).otherwise((req, res) -> { checker.handlerInvoked("headerIsNotValid"); })) .get("/equals", RequestPredicate.create() .containsHeader("my-header", "abc") .thenApply((req, resp) -> { checker.handlerInvoked("headerIsEqual"); }).otherwise((req, res) -> { checker.handlerInvoked("headerIsNotEqual"); })) .build(); assertThrows(NullPointerException.class, () -> { RequestPredicate.create() .containsHeader(null); }); routing.route(mockRequest("/exists", Map.of("my-header", List.of("abc"))), mockResponse()); assertThat(checker.handlersInvoked(), is("headerFound")); checker.reset(); routing.route(mockRequest("/exists", Map.of()), mockResponse()); assertThat(checker.handlersInvoked(), is("headerNotFound")); }
public RequestPredicate containsHeader(final String name) { return containsHeader(name, (c) -> true); }
RequestPredicate { public RequestPredicate containsHeader(final String name) { return containsHeader(name, (c) -> true); } }
RequestPredicate { public RequestPredicate containsHeader(final String name) { return containsHeader(name, (c) -> true); } private  RequestPredicate(); private  RequestPredicate(final RequestPredicate first,
            final Condition cond); }
RequestPredicate { public RequestPredicate containsHeader(final String name) { return containsHeader(name, (c) -> true); } private  RequestPredicate(); private  RequestPredicate(final RequestPredicate first,
            final Condition cond); ConditionalHandler thenApply(final Handler handler); boolean test(final ServerRequest request); RequestPredicate and(final Predicate<ServerRequest> predicate); RequestPredicate or(final Predicate<ServerRequest> predicate); RequestPredicate negate(); RequestPredicate isOfMethod(final String... methods); RequestPredicate isOfMethod(final Method... methods); RequestPredicate containsHeader(final String name); RequestPredicate containsHeader(final String name,
            final String value); RequestPredicate containsHeader(final String name,
            final Predicate<String> predicate); RequestPredicate containsQueryParameter(final String name); RequestPredicate containsQueryParameter(final String name,
            final String value); RequestPredicate containsQueryParameter(final String name,
            final Predicate<String> predicate); RequestPredicate containsCookie(final String name); RequestPredicate containsCookie(final String name,
            final String value); RequestPredicate containsCookie(final String name,
            final Predicate<String> predicate); RequestPredicate accepts(final String... contentType); RequestPredicate accepts(final MediaType... contentType); RequestPredicate hasContentType(final String... contentType); RequestPredicate hasContentType(final MediaType... contentType); static RequestPredicate create(); }
RequestPredicate { public RequestPredicate containsHeader(final String name) { return containsHeader(name, (c) -> true); } private  RequestPredicate(); private  RequestPredicate(final RequestPredicate first,
            final Condition cond); ConditionalHandler thenApply(final Handler handler); boolean test(final ServerRequest request); RequestPredicate and(final Predicate<ServerRequest> predicate); RequestPredicate or(final Predicate<ServerRequest> predicate); RequestPredicate negate(); RequestPredicate isOfMethod(final String... methods); RequestPredicate isOfMethod(final Method... methods); RequestPredicate containsHeader(final String name); RequestPredicate containsHeader(final String name,
            final String value); RequestPredicate containsHeader(final String name,
            final Predicate<String> predicate); RequestPredicate containsQueryParameter(final String name); RequestPredicate containsQueryParameter(final String name,
            final String value); RequestPredicate containsQueryParameter(final String name,
            final Predicate<String> predicate); RequestPredicate containsCookie(final String name); RequestPredicate containsCookie(final String name,
            final String value); RequestPredicate containsCookie(final String name,
            final Predicate<String> predicate); RequestPredicate accepts(final String... contentType); RequestPredicate accepts(final MediaType... contentType); RequestPredicate hasContentType(final String... contentType); RequestPredicate hasContentType(final MediaType... contentType); static RequestPredicate create();  }