I have spring gateway app with this configuration:
spring:
cloud:
gateway:
mvc:
http-client:
type: autodetect
routes:
- id: getCustomer
uri: ${services.side-service-uri}
predicates:
- Method=GET
- ExtractJWTTokenClaim=customerId
- Path=/v1/customers/customer
filters:
- SetPath=/api/customer/{customerId}
ExtractJWTTokenClaim
is a custom predicate which takes customerId
from jwt token and puts it uriVariables using MvcUtils.putUriTemplateVariables
. It’s logic is very similar to what we can see here
Everything is working fine with the configuration provided above. The problem starts when i want my custom predicate to be called after the Path
predicate so when i replace ExtractJWTTokenClaim
and Path
the filter SetPath
throws error java.lang.IllegalArgumentException: Map has no value for 'customerId'
I debugged the code and found out that everything works fine in my predicate, but this variables are gone when reaching SetPath
.
Why does it happen?