Remove ParsingPathMatcher

Now that we also have RequestPath and PathContainer with the latter as
the required input, the ParsingPathMatcher adapter can be removed.
This commit is contained in:
Rossen Stoyanchev
2017-08-01 13:35:21 +02:00
parent 4fc0ce1206
commit b1440b6816
7 changed files with 29 additions and 260 deletions

View File

@@ -25,13 +25,14 @@ import org.junit.Test;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
import org.springframework.http.server.PathContainer;
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.util.PathMatcher;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.util.pattern.ParsingPathMatcher;
import org.springframework.web.util.pattern.PathPattern;
import org.springframework.web.util.pattern.PathPatternParser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -137,7 +138,7 @@ public class HandlerMethodMappingTests {
private static class MyHandlerMethodMapping extends AbstractHandlerMethodMapping<String> {
private PathMatcher pathMatcher = new ParsingPathMatcher();
private PathPatternParser parser = new PathPatternParser();
@Override
protected boolean isHandler(Class<?> beanType) {
@@ -152,14 +153,14 @@ public class HandlerMethodMappingTests {
@Override
protected String getMatchingMapping(String pattern, ServerWebExchange exchange) {
String lookupPath = exchange.getRequest().getURI().getPath();
return (this.pathMatcher.match(pattern, lookupPath) ? pattern : null);
PathContainer lookupPath = exchange.getRequest().getPath().pathWithinApplication();
PathPattern parsedPattern = this.parser.parse(pattern);
return (parsedPattern.matches(lookupPath) ? pattern : null);
}
@Override
protected Comparator<String> getMappingComparator(ServerWebExchange exchange) {
String lookupPath = exchange.getRequest().getURI().getPath();
return this.pathMatcher.getPatternComparator(lookupPath);
return Comparator.comparing(o -> parser.parse(o));
}
}