Add syntactic sugar for URI paths (gh-3293)#4135
Add syntactic sugar for URI paths (gh-3293)#4135Arnav05-cyber wants to merge 2 commits intospring-cloud:mainfrom
Conversation
Signed-off-by: Arnav <arnav.vyas06@gmail.com>
spencergibb
left a comment
There was a problem hiding this comment.
I'll have to think about this, since RouteDefinitionRouteLocator is only one implementation of RouteLocator. Ideally this would work with any implementation.
| @@ -1,83 +1,47 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!-- | |||
| ~ Copyright 2013-2017 the original author or authors. | |||
There was a problem hiding this comment.
Please revert all changes to this file
Signed-off-by: Arnav <arnav.vyas06@gmail.com>
ccc0bbc to
bb9e5f1
Compare
|
Thanks for the feedback, @spencergibb I have reverted the changes to .settings.xml and fixed the DCO sign-off on that commit. Regarding the implementation: I see your point. By putting this in RouteDefinitionRouteLocator, it only benefits users defining routes via properties/YAML. Proposed Plan: I’m planning to move the path-detection and 'sugar' logic into the Route.Builder (specifically within the uri(URI uri) method). This would ensure that whether a route is created via the Java DSL, Discovery Client, or RouteDefinition, the path is correctly identified and a SetPath filter is added if missing. Please advise! |
Description
This Pull Request addresses issue #3293 by adding "syntactic sugar" for
RouteDefinitionURIs that contain a path component.Currently, if a user specifies a path in the URI (e.g.,
uri: https://example.com/foo/bar), the Gateway does not automatically handle the path mapping, often requiring an explicitSetPathfilter to avoid routing errors or double-pathing.Changes introduced in this PR:
RouteDefinitionRouteLocatornow checks if the provided URI has a non-root path.SetPathfilter is manually defined, aSetPathfilter is automatically added to the beginning of the filter chain.Testing
Added a new unit test
uriWithMappingShouldAddSetPathFilterinRouteDefinitionRouteLocatorTests.javato verify:SetPathfilter is correctly injected with the URI's path.RouteURI is correctly stripped of its path component.SetPathfilters and does not duplicate them.Signed-off-by: Arnav arnav.vyas06@gmail.com