use of cn.taketoday.http.server.PathContainer in project today-infrastructure by TAKETODAY.
the class PathPatternTests method extractPathWithinPatternCustomSeparator.
@Test
public void extractPathWithinPatternCustomSeparator() {
PathPatternParser ppp = new PathPatternParser();
ppp.setPathOptions(PathContainer.Options.create('.', true));
PathPattern pp = ppp.parse("test.**");
PathContainer pathContainer = PathContainer.parsePath("test.projects..spring-framework", PathContainer.Options.create('.', true));
PathContainer result = pp.extractPathWithinPattern(pathContainer);
assertThat(result.value()).isEqualTo("projects.spring-framework");
assertThat(result.elements()).hasSize(3);
}
use of cn.taketoday.http.server.PathContainer in project today-infrastructure by TAKETODAY.
the class PathPatternsRequestCondition method getMatchingCondition.
/**
* Checks if any of the patterns match the given request and returns an
* instance that is guaranteed to contain matching patterns, sorted.
*
* @param request the current request
* @return the same instance if the condition contains no patterns;
* or a new condition with sorted matching patterns;
* or {@code null} if no patterns match.
*/
@Override
@Nullable
public PathPatternsRequestCondition getMatchingCondition(RequestContext request) {
PathContainer path = request.getLookupPath().pathWithinApplication();
SortedSet<PathPattern> matches = getMatchingPatterns(path);
return matches != null ? new PathPatternsRequestCondition(matches) : null;
}
use of cn.taketoday.http.server.PathContainer in project today-infrastructure by TAKETODAY.
the class HandlerMatchingMetadata method pathWithinApplication.
@Experimental
public final PathContainer pathWithinApplication() {
PathContainer pathWithinApplication = this.pathWithinApplication;
if (pathWithinApplication == null) {
pathWithinApplication = requestPath.pathWithinApplication();
this.pathWithinApplication = pathWithinApplication;
}
return pathWithinApplication;
}
use of cn.taketoday.http.server.PathContainer in project today-framework by TAKETODAY.
the class HandlerMatchingMetadata method getPathWithinMapping.
public PathContainer getPathWithinMapping() {
PathContainer pathWithinMapping = this.pathWithinMapping;
if (pathWithinMapping == null) {
pathWithinMapping = getBestMatchingPattern().extractPathWithinPattern(requestPath);
this.pathWithinMapping = pathWithinMapping;
}
return pathWithinMapping;
}
use of cn.taketoday.http.server.PathContainer in project today-framework by TAKETODAY.
the class PathPatternsRequestCondition method getMatchingCondition.
/**
* Checks if any of the patterns match the given request and returns an
* instance that is guaranteed to contain matching patterns, sorted.
*
* @param request the current request
* @return the same instance if the condition contains no patterns;
* or a new condition with sorted matching patterns;
* or {@code null} if no patterns match.
*/
@Override
@Nullable
public PathPatternsRequestCondition getMatchingCondition(RequestContext request) {
PathContainer path = request.getLookupPath().pathWithinApplication();
SortedSet<PathPattern> matches = getMatchingPatterns(path);
return matches != null ? new PathPatternsRequestCondition(matches) : null;
}
Aggregations