'Spring Cloud Gateway route to itself
I have a scenario in an implementation of spring cloud gateway (Just for illustration call that service custom api gateway). In this 'Custom API Gateway' I want to define a route, filters, predicate and forward the request to a custom endpoint in the 'custom api gateway'? Is there a way to achieve that? Everything works except forwarding to a URI in the 'custom api gateway'
Here is an example
id: UpdateUser
uri: SHOULD NOT GO DOWNSTREAM (endpoint is in 'custom api gateway')
predicates:
- path=/api/users
filters:
- ValidateSession
Thanks Segi
Solution 1:[1]
You can define some controllers in spring cloud gateway and write routes to route requests to these controllers, but you should add uri changing filters like prefixPath, stripPrefix to change uri part to different one.
If you don't change the uri, requests will cause a 413 request entity too large error code, if you open debug level log, you'll see gateway is passing this request over and over again to itself.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
