I'm using 3.1.0 version for Spring Cloud Gateway and I need help in checking and fixing the Path predicate filter for my route configuration.
I'm trying to use regex in between a path, the route looks something like this in my config:
- id: Route1
uri: https://example.com
predicates:
- Path=/random/path/\d /update
- Method=POST
Though this is a valid regex, I'm getting 404 error code for requests for path :
/random/path/12/update
Hence I need help to figure out the correct configs for this usecase
CodePudding user response:
It requires a named path segment. See the syntax here. You can then use {mynum}
in filters like SetPath
- id: Route1
uri: https://example.com
predicates:
- Path=/random/path/{mynum:\d }/update
- Method=POST