Search in sources :

Example 6 with PathContainer

use of cn.taketoday.http.server.PathContainer in project today-framework 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 7 with PathContainer

use of cn.taketoday.http.server.PathContainer in project today-framework 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 8 with PathContainer

use of cn.taketoday.http.server.PathContainer in project today-framework by TAKETODAY.

the class PathPatternTests method checkMatches.

private void checkMatches(String uriTemplate, String path) {
    PathPatternParser parser = new PathPatternParser();
    parser.setMatchOptionalTrailingSeparator(true);
    PathPattern p = parser.parse(uriTemplate);
    PathContainer pc = toPathContainer(path);
    assertThat(p.matches(pc)).isTrue();
}
Also used : PathContainer(cn.taketoday.http.server.PathContainer)

Example 9 with PathContainer

use of cn.taketoday.http.server.PathContainer in project today-framework by TAKETODAY.

the class PathPatternTests method checkNoMatch.

private void checkNoMatch(String uriTemplate, String path) {
    PathPatternParser p = new PathPatternParser();
    PathPattern pattern = p.parse(uriTemplate);
    PathContainer PathContainer = toPathContainer(path);
    assertThat(pattern.matches(PathContainer)).isFalse();
}
Also used : PathContainer(cn.taketoday.http.server.PathContainer)

Example 10 with PathContainer

use of cn.taketoday.http.server.PathContainer in project today-infrastructure 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)

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