Minor refactoring in PathPattern
Rename getPathRemaining to matchStartOfPath since the method does match and to be more clear about what the method and the return value intuitively follows. Remove matchStart which matches the start of the pattern (rather than the start of the path). It is a use case that does not come up in request mapping.
This commit is contained in:
@@ -356,7 +356,7 @@ public abstract class RequestPredicates {
|
||||
|
||||
@Override
|
||||
public Optional<ServerRequest> nest(ServerRequest request) {
|
||||
return Optional.ofNullable(this.pattern.getPathRemaining(request.pathContainer()))
|
||||
return Optional.ofNullable(this.pattern.matchStartOfPath(request.pathContainer()))
|
||||
.map(info -> {
|
||||
mergeTemplateVariables(request, info.getUriVariables());
|
||||
return new SubPathServerRequestWrapper(request, info);
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.http.InvalidMediaTypeException;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.reactive.HandlerMapping;
|
||||
@@ -113,6 +114,8 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe
|
||||
else {
|
||||
bestPattern = patterns.iterator().next();
|
||||
PathPattern.PathMatchInfo result = bestPattern.matchAndExtract(lookupPath);
|
||||
Assert.notNull(result, () ->
|
||||
"Expected bestPattern: " + bestPattern + " to match lookupPath " + lookupPath);
|
||||
uriVariables = result.getUriVariables();
|
||||
matrixVariables = result.getMatrixVariables();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user