Expose RequestPath in ServerHttpRequest

The new structured getPath() method replaces the existing
getContextPath() + getPathWithinApplication().

Issue: SPR-15648
This commit is contained in:
Rossen Stoyanchev
2017-06-11 21:57:54 -04:00
parent 2d17411ec4
commit 38a12ed4ba
26 changed files with 127 additions and 115 deletions

View File

@@ -105,7 +105,7 @@ public class ContextPathCompositeHandlerTests {
new ContextPathCompositeHandler(map).handle(request, new MockServerHttpResponse());
assertTrue(handler.wasInvoked());
assertEquals("/yet/another/path", handler.getRequest().getContextPath());
assertEquals("/yet/another/path", handler.getRequest().getPath().contextPath().value());
}
@Test
@@ -133,7 +133,7 @@ public class ContextPathCompositeHandlerTests {
private void assertInvoked(TestHttpHandler handler, String contextPath) {
assertTrue(handler.wasInvoked());
assertEquals(contextPath, handler.getRequest().getContextPath());
assertEquals(contextPath, handler.getRequest().getPath().contextPath().value());
}
private void assertNotInvoked(TestHttpHandler... handlers) {

View File

@@ -56,7 +56,7 @@ public class RxNettyServerHttpRequest extends AbstractServerHttpRequest {
NettyDataBufferFactory dataBufferFactory, InetSocketAddress remoteAddress)
throws URISyntaxException {
super(initUri(request, remoteAddress), initHeaders(request));
super(initUri(request, remoteAddress), "", initHeaders(request));
this.request = request;
Assert.notNull(dataBufferFactory, "NettyDataBufferFactory must not be null");

View File

@@ -56,8 +56,6 @@ public class MockServerHttpRequest extends AbstractServerHttpRequest {
private final HttpMethod httpMethod;
private final String contextPath;
private final MultiValueMap<String, HttpCookie> cookies;
private final InetSocketAddress remoteAddress;
@@ -70,9 +68,8 @@ public class MockServerHttpRequest extends AbstractServerHttpRequest {
InetSocketAddress remoteAddress,
Publisher<? extends DataBuffer> body) {
super(uri, headers);
super(uri, contextPath, headers);
this.httpMethod = httpMethod;
this.contextPath = (contextPath != null ? contextPath : "");
this.cookies = cookies;
this.remoteAddress = remoteAddress;
this.body = Flux.from(body);
@@ -89,11 +86,6 @@ public class MockServerHttpRequest extends AbstractServerHttpRequest {
return this.httpMethod.name();
}
@Override
public String getContextPath() {
return this.contextPath;
}
@Override
public InetSocketAddress getRemoteAddress() {
return this.remoteAddress;