preserve target paths on mvc gateways#3260
preserve target paths on mvc gateways#3260Interessierter wants to merge 1 commit intospring-cloud:mainfrom
Conversation
the previous implementation completely removed the path of the configured target which is unexpected and did not match the API (target is given as URI (string) which naturally can contain paths)
|
@Interessierter Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
|
@Interessierter Thank you for signing the Contributor License Agreement! |
|
This is the existing behaviour of the reactive gateway. Any changes to the path should be made by a filter. |
|
@spencergibb that's a real pity because as I wrote the API suggests that you can use "real" URIs as target where you can in fact just use server addresses without any paths - IMHO the documentation should be updated to reflect this fact, this will save new developers lots of time - maybe a hint here: https://docs.spring.io/spring-cloud-gateway/reference/spring-cloud-gateway-server-mvc/java-routes-api.html#gateway-handlerfunctions would be good. and FYI in #3162 another user is complaining about exactly the same "feature" |
|
@Interessierter see #3292 for the documentation issue. You've convinced me that the feature would be welcome. I've opened #3293 to track it as I see how it should work. |
the previous implementation completely removed the path of the configured target which is unexpected and did not match the API (target is given as URI (string) which naturally can contain paths)
I created and attached a small project to reproduce the issue with the current code, see GatewayConfiguration.java:
So when calling http://localhost:8080/gateway/hello it is expected to see the content from http://localhost:8080/finallevel/hello but instead the content of http://localhost:8080/hello only is displayed.
Of course this example is contrieved and that case can here simply be circumvented by adding a
before(prefixPath("finallevel"))to the route builder but my usecase is to determine the target dynamically (which is advertised in the documentation and a really useful feature), some targets have a path, some dontgateway-pathsgone.zip