Skip to content

preserve target paths on mvc gateways#3260

Closed
Interessierter wants to merge 1 commit intospring-cloud:mainfrom
Interessierter:fixes-mvc-target-path
Closed

preserve target paths on mvc gateways#3260
Interessierter wants to merge 1 commit intospring-cloud:mainfrom
Interessierter:fixes-mvc-target-path

Conversation

@Interessierter
Copy link
Copy Markdown

@Interessierter Interessierter commented Feb 9, 2024

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:

        return route().GET("/gateway/**", http("http://localhost:8080/finallevel"))
                .before(stripPrefix(1))
                .build();

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 dont

gateway-pathsgone.zip

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)
@pivotal-cla
Copy link
Copy Markdown

@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.

@pivotal-cla
Copy link
Copy Markdown

@Interessierter Thank you for signing the Contributor License Agreement!

@spencergibb
Copy link
Copy Markdown
Member

This is the existing behaviour of the reactive gateway. Any changes to the path should be made by a filter.

@Interessierter
Copy link
Copy Markdown
Author

@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"

@spencergibb
Copy link
Copy Markdown
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants