spring-cloud/spring-cloud-gateway

More flexible path matching (such as file extensions and logical or)

Open

#672 geöffnet am 22. Nov. 2018

Auf GitHub ansehen
 (13 Kommentare) (1 Reaktion) (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

Bug report

spring-cloud-version: Finchley.SR2

I has a requirement that route www.example.com/**/*.html to lb://serviceNodeJs, and route www.example.com/** to lb://serviceJava, so I wrote the following yaml file:

spring:
  cloud:
    gateway:
      routes:
      - id: test1
        uri: lb://serviceNodeJs
        predicates:
        - Host=www.example.com
        - Path=/**/*.html
      - id: test2
        uri: lb://serviceJava
        predicates:
        - Host=www.example.com
        - Path=/**

But when I browse http://www.example.com/index.html, it is routed to lb://serviceJava, my idea is that all the requests with the .html postfix being routed to lb://serviceNodeJs, and all the others being routed to lb://serviceJava, And I have also read the source code PathRoutePredicateFactory, I found that it use a new class PathPattern to test if it matches. If I use AntPathMatcher, it can support my requirement. so can PathPattern changed to meet this requirement?

Contributor Guide