'Spring cloud gateway support for services running on non-root URLs
Our spring cloud gateway needs to support services located in non-root URLs. For example:
https://thehost/api/theservice
I can configure the service using SimpleDiscoveryClient and SimpleReactiveDiscoveryClient or I can create my own implementation of the discovery clients. However, no matter what I do I'm still limited by this interface:
ServiceInstance
This interface has a nice method getUri(), which default implementation implements poorly and loses everything except host, port and scheme. I can provide my own implementation, but unfortunately this method:
LoadBalancerUriTools.doReconstructURI()
which the ReactiveLoadBalancerClientFilter relies on to reconstruct URI, ignores all the complexity of the original URI and in my example results in this:
https://thehost:443/theresource
Note that it hardcodes the port for https URI as well, which is not good either.
I'd like this functionality to respect the original configuration and construct the following instead:
https://thehost/api/theservice/theresource
Is there way to achieve a proper service URL handling? Maybe there's a way to customize the behavior somehow?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
