Path RequestPredicate should honor servlet path
Closes gh-23841
This commit is contained in:
@@ -54,8 +54,10 @@ import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.HttpMediaTypeNotSupportedException;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
|
||||
import org.springframework.web.util.UriBuilder;
|
||||
import org.springframework.web.util.UrlPathHelper;
|
||||
|
||||
/**
|
||||
* {@code ServerRequest} implementation based on a {@link HttpServletRequest}.
|
||||
@@ -111,6 +113,16 @@ class DefaultServerRequest implements ServerRequest {
|
||||
return ServletUriComponentsBuilder.fromRequest(servletRequest());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String path() {
|
||||
String path = (String) servletRequest().getAttribute(HandlerMapping.LOOKUP_PATH);
|
||||
if (path == null) {
|
||||
UrlPathHelper helper = new UrlPathHelper();
|
||||
path = helper.getLookupPathForRequest(servletRequest());
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Headers headers() {
|
||||
return this.headers;
|
||||
|
||||
@@ -168,6 +168,8 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini
|
||||
@Nullable
|
||||
@Override
|
||||
protected Object getHandlerInternal(@NotNull HttpServletRequest servletRequest) throws Exception {
|
||||
String lookupPath = getUrlPathHelper().getLookupPathForRequest(servletRequest);
|
||||
servletRequest.setAttribute(LOOKUP_PATH, lookupPath);
|
||||
if (this.routerFunction != null) {
|
||||
ServerRequest request = ServerRequest.create(servletRequest, this.messageConverters);
|
||||
servletRequest.setAttribute(RouterFunctions.REQUEST_ATTRIBUTE, request);
|
||||
|
||||
Reference in New Issue
Block a user