Modify getPathRemaining to return remaining path and bound variables

Without this change it was necessary to call getPathRemaining and
then chop up the path and make a call to matchAndExtract to get the
bound variables for the path part that matched. With this change
this is all done in the call to getPathRemaining which returns
an object holding the remaining path and the bound variables.

Issue: SPR-15419
This commit is contained in:
Andy Clement
2017-04-14 07:48:51 -07:00
parent 88f8df4dce
commit 316a680577
4 changed files with 136 additions and 36 deletions

View File

@@ -42,6 +42,7 @@ import org.springframework.web.server.WebSession;
import org.springframework.web.util.UriUtils;
import org.springframework.web.util.patterns.PathPattern;
import org.springframework.web.util.patterns.PathPatternParser;
import org.springframework.web.util.patterns.PathRemainingMatchInfo;
/**
* Implementations of {@link RequestPredicate} that implement various useful
@@ -353,7 +354,8 @@ public abstract class RequestPredicates {
@Override
public Optional<ServerRequest> nest(ServerRequest request) {
String remainingPath = this.pattern.getPathRemaining(request.path());
PathRemainingMatchInfo info = this.pattern.getPathRemaining(request.path());
String remainingPath = (info == null ? null : info.getPathRemaining());
return Optional.ofNullable(remainingPath)
.map(path -> !path.startsWith("/") ? "/" + path : path)
.map(path -> {