-
Notifications
You must be signed in to change notification settings - Fork 1.7k
#360 Routing based on values in designated upstream request headers #1684
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
base: develop
Are you sure you want to change the base?
#360 Routing based on values in designated upstream request headers #1684
Conversation
Zbyněk, thanks for the great PR! 💪 Does the PR close the #624 ? I am a bit confused by this PR because you said that it makes little sense to me to keep working on this any longer. |
Zbyněk, |
Well, you wanted to salvage my changes from the old branch, so I thought it shouldn't hurt to just to take them and put them in a new branch. 😄 At any rate, I have been thinking about the practical benefit of the current solution. You see, since users will still have to provide unique upstream URL for different downstreams, I thought that maybe we could consider allowing identical upstream URL, but differentiating the mappings based on the headers.It kind of makes sense in my head, but let me know what you and maybe also other maintainers think. EDIT: Actually, just looking at the first post in #360 , it becomes clear that the above is a requirement, not just an option. I will have to look into allowing it as it looks like Ocelot currently won't allow multiple upstream routes to be the same. |
src/Ocelot/Configuration/File/FileUpstreamHeaderRoutingOptions.cs
Outdated
Show resolved
Hide resolved
src/Ocelot/Configuration/File/FileUpstreamHeaderRoutingOptions.cs
Outdated
Show resolved
Hide resolved
src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteFinder.cs
Outdated
Show resolved
Hide resolved
src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteFinder.cs
Outdated
Show resolved
Hide resolved
Cheers for the feedback, @RaynaldM . I have integrated it along with a modification to the |
src/Ocelot/Configuration/Validator/FileConfigurationFluentValidator.cs
Outdated
Show resolved
Hide resolved
src/Ocelot/Configuration/Validator/FileConfigurationFluentValidator.cs
Outdated
Show resolved
Hide resolved
Having taken a look at how URL placeholder extraction and replacement works, it's quite obvious that the current algorithm (implemented in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrclayman Hi Zbyněk!
Some suggestions:
- Use file-scoped namespaces for new added files always, because we have .NET 6+ environment
- Remove and Sort Usings by standard refactoring action in Visual Studio. I see you use some other RAD tool.
- Use
var
option to define a variable for reference types
Don't judge me much while resolving these issues please! 🤣 👇
Helpful unit tests:
src/Ocelot/Configuration/Creator/UpstreamHeaderRoutingOptionsCreator.cs
Outdated
Show resolved
Hide resolved
src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteFinder.cs
Outdated
Show resolved
Hide resolved
src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteFinder.cs
Outdated
Show resolved
Hide resolved
src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteFinder.cs
Outdated
Show resolved
Hide resolved
test/Ocelot.UnitTests/DownstreamRouteFinder/DownstreamRouteFinderTests.cs
Outdated
Show resolved
Hide resolved
test/Ocelot.UnitTests/DownstreamRouteFinder/DownstreamRouteFinderTests.cs
Outdated
Show resolved
Hide resolved
This is crazy idea! Why not to fix code review issues first? 😉 |
I work in Linux. There is no Visual Studio for that. I have already had to disable |
Ping @raman-m, hope you didn't fall off the edge of the earth. 🙂 |
c216cdf
to
b458f0f
Compare
908d84f
to
0678e7a
Compare
Closes #360
Addition of support for request re-routing based also on upstream header configuration as per issues
Proposed Changes
Downstream URL placeholder replacement mentioned in issue #360 is not yet supported although I do have plans to add support for that as well.