use of org.springframework.web.util.pattern.PathPattern in project spring-framework by spring-projects.
the class PatternsRequestCondition method getDirectPaths.
/**
* Return the mapping paths that are not patterns.
* @since 5.3
*/
public Set<String> getDirectPaths() {
if (isEmptyPathMapping()) {
return EMPTY_PATH;
}
Set<String> result = Collections.emptySet();
for (PathPattern pattern : this.patterns) {
if (!pattern.hasPatternSyntax()) {
result = (result.isEmpty() ? new HashSet<>(1) : result);
result.add(pattern.getPatternString());
}
}
return result;
}
use of org.springframework.web.util.pattern.PathPattern in project spring-framework by spring-projects.
the class PatternsRequestCondition method getMatchingPatterns.
@Nullable
private SortedSet<PathPattern> getMatchingPatterns(ServerWebExchange exchange) {
PathContainer lookupPath = exchange.getRequest().getPath().pathWithinApplication();
TreeSet<PathPattern> result = null;
for (PathPattern pattern : this.patterns) {
if (pattern.matches(lookupPath)) {
result = (result != null ? result : new TreeSet<>());
result.add(pattern);
}
}
return result;
}
use of org.springframework.web.util.pattern.PathPattern in project spring-framework by spring-projects.
the class RequestMappingInfoHandlerMappingTests method handleMatchBestMatchingPatternAttributeNoPatternsDefined.
// gh-22543
@Test
public void handleMatchBestMatchingPatternAttributeNoPatternsDefined() {
ServerWebExchange exchange = MockServerWebExchange.from(get(""));
this.handlerMapping.handleMatch(paths().build(), handlerMethod, exchange);
PathPattern pattern = (PathPattern) exchange.getAttributes().get(BEST_MATCHING_PATTERN_ATTRIBUTE);
assertThat(pattern.getPatternString()).isEqualTo("");
}
use of org.springframework.web.util.pattern.PathPattern in project spring-framework by spring-projects.
the class RequestMappingHandlerMappingTests method assertComposedAnnotationMapping.
private RequestMappingInfo assertComposedAnnotationMapping(String methodName, String path, RequestMethod requestMethod) throws Exception {
Class<?> clazz = ComposedAnnotationController.class;
Method method = ClassUtils.getMethod(clazz, methodName, (Class<?>[]) null);
RequestMappingInfo info = this.handlerMapping.getMappingForMethod(method, clazz);
assertThat(info).isNotNull();
Set<PathPattern> paths = info.getPatternsCondition().getPatterns();
assertThat(paths.size()).isEqualTo(1);
assertThat(paths.iterator().next().getPatternString()).isEqualTo(path);
Set<RequestMethod> methods = info.getMethodsCondition().getMethods();
assertThat(methods.size()).isEqualTo(1);
assertThat(methods.iterator().next()).isEqualTo(requestMethod);
return info;
}
Aggregations