I want to capture the value from my CountryCode header and use that to set my path, see this config for a simplified example of what I am trying to achieve:
spring:
cloud:
gateway:
routes:
- id: custom_route
uri: http://example.org
predicates:
- Path=/user
- Header=CountryCode, {countryCode:[A-Z]{2}}
filters:
- SetPath=/{countryCode}/user
- RemoveRequestHeader=CountryCode
Is it possible to do this with some kind of capture group, regex or pattern matching on the value of the CountryCode header? The example above is my understanding of how the pattern matching in Spring Cloud Gateway works, but the only example I could find of a header predicate was:
predicates:
- Header=X-Request-Id, \d+
and I can neither get my example to work, nor does the example appear to be able to capture the header value. I can imagine there is a way to do this in Java, but is it possible to do it in the application.yml instead?