-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Have Routes Support Multiple URIs #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It would have to return something structured. Like
Something automated. Maybe some kind of non-blocking template
|
@spencergibb I have been thinking more about this recently...wondering what you thought of this
Some import things of note
|
I'd love to have this feature for BFFs. We're currently investigating using Gateway for BFF endpoints that can be directly proxied downstream but when composing APIs we still have to create controllers and manually handle requests to have parity with all the things Gateway does. |
I think we could get there. A couple of issues to consider: transforming individual responses (which we're working on) and combining the multiple requests. I was thinking of maybe using something like timeleaf(sp?) That supports reactive templates. |
I have been working on prototyping this, stay tuned for more updates as I play around with things. |
So wouldn't the nested routes under a composite route make binding a little trickier and yaml structure a bit more complicated? I've been poking around with a different approach that would use the existing YAML structure and do the work in filters: There's a The forking filter makes a request to The joining filter grabs the response monos out of the exchange attribute, transforms the responses from Sample java config
super rough output :
I'm not sure if the |
@fitzoh what if in the filters i want to apply things like filters to modify the request/response for each route individually? The is why I liked referencing existing route definitions. I wanted to run each route of the "composite" through the existing |
That makes sense @ryanjbaxter, but the predicates feel a little weird to me in that approach. Do we just ignore the top level predicates for composite routes? Can there be additional predicates within a composite route that do get honored? (ie maybe we never want it to be available as a top level route, and only sometimes get called as a composite route) On an overall feature level I feel like this has the potential to add a lot of cognitive overhead, and config file support would leave you w/ too much yaml to make sense of (at least for me), especially for figuring out how to reassemble downstream requests in a way that makes sense. To me this seems like something that should be done in code, potentially w/ some utility functions to make it a bit less awkward. |
Dave added the |
What's the status of this? Think it will be a really cool feature. |
No change in status |
I feel like this might be similarly related. If I want to do a conditional flow e.g. uri targeta = "uria" What would be the proper way to express something like this? |
@dave-fl predicates are booleans, so two different routes with appropriate predicates (you can use |
Thank you @spencergibb Let me add some more details. The input to the predicate will only be known at runtime - can I have a custom predicate to determine this? targeta and targetb must be discovered at runtime (they are not fixed and must be sourced from another service) - how can I set the URI dynamically? Additionally if I visit targetb and the response is successful, I would like to revisit targeta. |
That seems beyond the scope of this issue. Any filter can set the uri. Something custom is your only solution ATM. |
Is there any status update on this? |
Nothing yet |
@ryanjbaxter any updates on when can we expect this feature ? |
There are currently no plans right now |
Not sure why it got added to a project |
Would love to have this feature as well. Anyway we can upvote this issue to help prioritize? |
@natraj09 add your thumbs up here #114 (comment) This would be a major feature and we already have a programmatic way to do this with |
Hi, Sorry I may missed but is multiple URIs already supported. I am thinking of using this feature for legacy systems. I can do work around by registering in eureka in behalf of the legacy apps. But it would be nice if gateway supports this. |
@sincang no it is not supported yet |
Hello Spring Cloud Gateway Team, This would be a great feature! |
Hi SCG Team, I am building an api gateway using SCG. There are some cases where we need to make 3 sequence of requests to different URIs for a single request. The output of 1st request is the input / path param / headers for subsequent request. And we expect the response are aggregated sometimes, and sometimes we need the 2nd request response. If SCG supports this feature, it would have been a best feature in it. Thanks. |
@sthanaraju What you are describing and what is being asked from here seem to be two different things.
If you need to do this, just use |
You could also use |
@spencergibb I noticed that in the documentation If it is possible, this should really leverage functional endpoints as they seem to operate at an order of magnitude faster relative to their annotated counterparts. |
The webflux version is new https://cloud.spring.io/spring-cloud-gateway/2.1.x/multi/multi__building_a_simple_gateway_using_spring_mvc_or_webflux.html Gateway has no functional endpoint functionality yet. |
Is there any news on this? We tried to create a custom filter, which can do a rest call via webclient, but the big problem i see is that i need to pass in a uri for proxying the request to. In this case I would rather have a terminal filter (or so) which resolves all mono's and returns the response body to the browser. I've read that there is a programmatic way, can you give an example on this? |
Hi , I have a requirement, that is i will receive XML request and i need to split into small and send these xml's to down the service, also vice-versa once receive multiple responses from the server , i need to club into one and send back this to client. Is this possible in spring-cloud gateway ? |
ForkingGatewayFilterFactory has issue not clearing prvous post requests, any idea ? |
Came across this thread because I am doing some Axway/Vordel policy ports and was trying SCG on for size. The requirement is to be able to call an authentication endpoint first prior to sending on to the actual endpoint. How about something along the lines of: spring: So {next:} only forwards to another route when there are no errors... |
This feature would indeed be quite useful. Just in case it's useful for anyone else, I provide the base implementation here (it may need some rework, but it should be enough to make the point). Simply put, I have a "base" service retrieving something like this:
And I want to enrich these entries with the actual So, I created my Filter based on the ModifyResponseBody one:
For completeness, this is the corresponding route setup using my Filter:
And with this, my resulting response looks as follows:
|
I currently have a requirement on similar lines. 1 request to the gateway needs to be routed to 2 different service providing uris (preferable parallelly) and somehow both the responses need to be sent back to the requestor. Is this possible with the current features of spring boot gateway. |
Interested in such feature as well. Any update? |
It would be nice if a route could be configured to make requests to multiple URIs and then return the results to a specified controller to aggregate the responses.
The controller,
blah
in this case, would take the result of calling thegreeting
andname
services and return a response for the client.For example if the greeting service returned
Hello
and the name service returnedRyan
. The controller would returnHello Ryan
.The text was updated successfully, but these errors were encountered: