spring-cloud/spring-cloud-gateway

Create a Glob Path Predicate

Open

#246 geöffnet am 25. März 2018

Auf GitHub ansehen
 (5 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Java (3.204 Forks)batch import
enhancementhelp wanted

Repository-Metriken

Stars
 (4.284 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 1T 21h) (18 gemergte PRs in 30 T)

Beschreibung

The documentation for the path predicate states that:

The Path Route Predicate Factory takes one parameter: a Spring PathMatcher pattern.

However, instead of the PathMatcher, the PathRoutePredicateFactory seems to be using a PathPatternParser which then fails to match on an AntPathMatcher match (Spring URI matching is documented here and explicitly mentions GLOB matching):

    matcher = new AntPathMatcher();
    assertTrue(matcher.match("/**/trigger", "/foo/bar/trigger"));

while the above works, this doesn't:

        .route(r ->
            r.path("/**/trigger")
              .filters(f -> f.filter(filter))
              .uri("http://localhost:9052")
        )

This prevents us from routing requests matching on GLOBs (and manually matching on every possible variation of the URL pattern would be tedious; hard to maintain; and error-prone).

Alternatively, consider adding a globPath predicate.

PS - AFAICT configuring match predicates via the YAML configuration does NOT seem to work.

Contributor Guide