private ServerWebExchange mapExchange(ServerWebExchange exchange, String methodParamValue) { HttpMethod httpMethod = HttpMethod.resolve(methodParamValue.toUpperCase(Locale.ENGLISH)); Assert.notNull(httpMethod, () -> "HttpMethod '" + methodParamValue + "' not supported"); if (ALLOWED_METHODS.contains(httpMethod)) { return exchange.mutate().request(builder -> builder.method(httpMethod)).build(); } else { return exchange; } }
private ServerWebExchange mapExchange(ServerWebExchange exchange, String methodParamValue) { HttpMethod httpMethod = HttpMethod.resolve(methodParamValue.toUpperCase(Locale.ENGLISH)); Assert.notNull(httpMethod, () -> "HttpMethod '" + methodParamValue + "' not supported"); if (ALLOWED_METHODS.contains(httpMethod)) { return exchange.mutate().request(builder -> builder.method(httpMethod)).build(); } else { return exchange; } }
@Test public void mutateRequest() throws Exception { SslInfo sslInfo = mock(SslInfo.class); ServerHttpRequest request = createHttpRequest("/").mutate().sslInfo(sslInfo).build(); assertSame(sslInfo, request.getSslInfo()); request = createHttpRequest("/").mutate().method(HttpMethod.DELETE).build(); assertEquals(HttpMethod.DELETE, request.getMethod()); String baseUri = "http://aaa.org:8080/a"; request = createHttpRequest(baseUri).mutate().uri(URI.create("http://bbb.org:9090/b")).build(); assertEquals("http://bbb.org:9090/b", request.getURI().toString()); request = createHttpRequest(baseUri).mutate().path("/b/c/d").build(); assertEquals("http://aaa.org:8080/b/c/d", request.getURI().toString()); request = createHttpRequest(baseUri).mutate().path("/app/b/c/d").contextPath("/app").build(); assertEquals("http://aaa.org:8080/app/b/c/d", request.getURI().toString()); assertEquals("/app", request.getPath().contextPath().value()); }
private ServerWebExchange mapExchange(ServerWebExchange exchange, String methodParamValue) { HttpMethod httpMethod = HttpMethod.resolve(methodParamValue.toUpperCase(Locale.ENGLISH)); Assert.notNull(httpMethod, () -> "HttpMethod '" + methodParamValue + "' not supported"); if (ALLOWED_METHODS.contains(httpMethod)) { return exchange.mutate().request(builder -> builder.method(httpMethod)).build(); } else { return exchange; } }
private ServerWebExchange mapExchange(ServerWebExchange exchange, String methodParamValue) { HttpMethod httpMethod = HttpMethod.resolve(methodParamValue.toUpperCase(Locale.ENGLISH)); Assert.notNull(httpMethod, () -> "HttpMethod '" + methodParamValue + "' not supported"); if (ALLOWED_METHODS.contains(httpMethod)) { return exchange.mutate().request(builder -> builder.method(httpMethod)).build(); } else { return exchange; } }