Search in sources :

Example 1 with PathContainer

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);
}
Also used : PathContainer(cn.taketoday.http.server.PathContainer) Test(org.junit.jupiter.api.Test)

Example 2 with PathContainer

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;
}
Also used : PathContainer(cn.taketoday.http.server.PathContainer) PathPattern(cn.taketoday.web.util.pattern.PathPattern) Nullable(cn.taketoday.lang.Nullable)

Example 3 with PathContainer

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;
}
Also used : PathContainer(cn.taketoday.http.server.PathContainer) Experimental(cn.taketoday.lang.Experimental)

Example 4 with PathContainer

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;
}
Also used : PathContainer(cn.taketoday.http.server.PathContainer)

Example 5 with PathContainer

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;
}
Also used : PathContainer(cn.taketoday.http.server.PathContainer) PathPattern(cn.taketoday.web.util.pattern.PathPattern) Nullable(cn.taketoday.lang.Nullable)

Aggregations

PathContainer (cn.taketoday.http.server.PathContainer)12 Experimental (cn.taketoday.lang.Experimental)2 Nullable (cn.taketoday.lang.Nullable)2 PathPattern (cn.taketoday.web.util.pattern.PathPattern)2 Test (org.junit.jupiter.api.Test)2