spring-cloud / spring-cloud/spring-cloud-gateway
More flexible path matching (such as file extensions and logical or)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.9k
- Forks
- 3.5k
- Avg merge
- 20h 57m
- Merged PRs (30d)
- 8
Description
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading PathRoutePredicateFactory and the PathPattern implementation referenced in the issue, then reproduce the two route configurations against the reported URL. Define the matching behavior for the .html pattern and the fallback pattern, including whether the broader logical-or request is in scope; done means the intended routes are selected consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100