You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I would like to be able to build upstream service URI based on components of the request. For instance given a request with the path /api/{serviceName} I would like to build the upstream URI using the serviceName piece like so:
Describe the solution you'd like
For the fluent routes (RouteLocatorBuilder) one solution might be to introduce another method e.g. uriBuilder which will have access to request details:
@Bean
public RouteLocator routes(RouteLocatorBuilder builder) {
return builder.routes()
.route("dynamic-route", predicate -> predicate.path(/api/**))
.uriBuilder(request -> {
String serviceName = "todo"; //extract service name from the reqeust's path
return "http://host:" + ports.get(serviceName) + "/"
})
.build();
}
Describe alternatives you've considered
I couldn't find any alternatives. The closest I could find was the RewritePath GatewayFilter but it allows only for rewriting the path part of the URI.
The text was updated successfully, but these errors were encountered:
@dharezlak yes I think that is the best solution at the moment. Unfortunately this means the URI of the route is pretty much useless which is kind of nasty. I think we need a cleaner solution to this problem.
Is your feature request related to a problem? Please describe.
I would like to be able to build upstream service URI based on components of the request. For instance given a request with the path
/api/{serviceName}
I would like to build the upstream URI using theserviceName
piece like so:Describe the solution you'd like
For the fluent routes (
RouteLocatorBuilder
) one solution might be to introduce another method e.g.uriBuilder
which will have access to request details:Describe alternatives you've considered
I couldn't find any alternatives. The closest I could find was the
RewritePath GatewayFilter
but it allows only for rewriting the path part of the URI.The text was updated successfully, but these errors were encountered: