Reputation: 63
I have a custom gateway filter that use the route written in application.yml, When I want to change the route predicate from /test/myTest to /public the request return 404 it seemes like the "/" is not reconized because I tried to change /test-myTest to /public and it's work.
Any idea please how can I use a predicate with this format /name/name/**
this is my application.yml :
myTest-gateway:
default-uri: https://app
apps:
/test/myTest: mymicroservice-name
spring:
cloud:
gateway:
enabled: false
x-forwarded:
proto-enabled: false
routes:
- id: appsPrefixPathPublic
uri: ${myTest-gateway.default-uri}
predicates:
- AppPath=/test/myTest
filters:
- StripPrefix=1
- PrefixPath=/public
this is the error that I got it :
No content
< 404 NOT_FOUND Not Found < Content-Type: [application/json] < Content-Length: [147]
{"timestamp":"2020-08-26T15:44:12.023+0000","path":"/test/myTest/whatever","status":404,"error":"Not Found","message":null,"requestId":"e7baeeeb-6"}
java.lang.AssertionError: Status expected:<200 OK> but was:<404 NOT_FOUND>
Upvotes: 1
Views: 9680
Reputation: 3465
From the documentation :
spring:
cloud:
gateway:
routes:
- id: nameRoot
uri: https://nameservice
predicates:
- Path=/name/**
filters:
- StripPrefix=2
When a request is made through the gateway to /name/blue/red
, the request made to nameservice
looks like nameservice/red
.
You should change 1 to 2.
Upvotes: 2