@Test public void failsIfRequestMethodIsNotSupported() throws Exception { WebServiceHandler handler = mock(WebServiceHandler.class); HttpMethodFilteringHandler post = new HttpMethodFilteringHandler(GET, handler); HttpRequest request = post("/some-uri").build(); HttpResponse response = Mono.from(post.handle(request, requestContext())).block(); assertThat(response.status(), is(METHOD_NOT_ALLOWED)); }
@Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { if (!method.equals(request.method())) { return Eventual.of( HttpResponse.response(METHOD_NOT_ALLOWED) .body(errorBody, StandardCharsets.UTF_8) .build() ); } return httpHandler.handle(request, context); }
HttpMethodFilteringHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { if (!method.equals(request.method())) { return Eventual.of( HttpResponse.response(METHOD_NOT_ALLOWED) .body(errorBody, StandardCharsets.UTF_8) .build() ); } return httpHandler.handle(request, context); } }
HttpMethodFilteringHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { if (!method.equals(request.method())) { return Eventual.of( HttpResponse.response(METHOD_NOT_ALLOWED) .body(errorBody, StandardCharsets.UTF_8) .build() ); } return httpHandler.handle(request, context); } HttpMethodFilteringHandler(HttpMethod method, WebServiceHandler httpHandler); }
HttpMethodFilteringHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { if (!method.equals(request.method())) { return Eventual.of( HttpResponse.response(METHOD_NOT_ALLOWED) .body(errorBody, StandardCharsets.UTF_8) .build() ); } return httpHandler.handle(request, context); } HttpMethodFilteringHandler(HttpMethod method, WebServiceHandler httpHandler); @Override Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context); }
HttpMethodFilteringHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { if (!method.equals(request.method())) { return Eventual.of( HttpResponse.response(METHOD_NOT_ALLOWED) .body(errorBody, StandardCharsets.UTF_8) .build() ); } return httpHandler.handle(request, context); } HttpMethodFilteringHandler(HttpMethod method, WebServiceHandler httpHandler); @Override Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context);  }