Respect context path in WebMvc.fn & WebFlux.fn
This commit makes several changes in both WebMvc.fn as well as WebFlux.fn. - ServerRequest now exposes a RequestPath through requestPath(), and pathContainer() has been deprecated. - The PathPredicate and PathResourceLookupFunction now respects this RequestPath's pathInApplication() in their path-related functionality. - When nesting, the PathPredicate now appends the matched part of the path to the current context path, instead of removing the matched part (which was done previously). This has the same result: the matched part is gone, but now the full path stays the same. Closes gh-25270
This commit is contained in:
@@ -41,7 +41,6 @@ import org.springframework.http.HttpRange;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.codec.HttpMessageReader;
|
||||
import org.springframework.http.codec.multipart.Part;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.http.server.RequestPath;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -69,7 +68,7 @@ public final class MockServerRequest implements ServerRequest {
|
||||
|
||||
private final URI uri;
|
||||
|
||||
private final RequestPath pathContainer;
|
||||
private final RequestPath requestPath;
|
||||
|
||||
private final MockHeaders headers;
|
||||
|
||||
@@ -88,7 +87,7 @@ public final class MockServerRequest implements ServerRequest {
|
||||
private final WebSession session;
|
||||
|
||||
@Nullable
|
||||
private Principal principal;
|
||||
private final Principal principal;
|
||||
|
||||
@Nullable
|
||||
private final InetSocketAddress remoteAddress;
|
||||
@@ -111,7 +110,7 @@ public final class MockServerRequest implements ServerRequest {
|
||||
|
||||
this.method = method;
|
||||
this.uri = uri;
|
||||
this.pathContainer = RequestPath.parse(uri, contextPath);
|
||||
this.requestPath = RequestPath.parse(uri, contextPath);
|
||||
this.headers = headers;
|
||||
this.cookies = cookies;
|
||||
this.body = body;
|
||||
@@ -148,8 +147,8 @@ public final class MockServerRequest implements ServerRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathContainer pathContainer() {
|
||||
return this.pathContainer;
|
||||
public RequestPath requestPath() {
|
||||
return this.requestPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user