Match multiple ocelot routes for given downstream endpoint #284
+289
−85
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Downstream paths are matched against all relevant Ocelot routes and used all routes that fit. Consider following downstream API:
GET /api/test
POST /api/test
Which is represented in OpenApi JSON as:
And this
ocelot.json
:So both API endpoints are mapped to
/all/ocelot
route, butPOST
endpoint is also mapped to/post/ocelot
.Former implementation of generating Swagger JSON file worked this way
/api/test
) found first suitable Ocelot route, which was/post/ocelot
.GET
,POST
in this case) and checked if matched route can handle these methods.GET
method is not in the first route, so it was removed from downstream.New implementation in this PR
Key changes in implementation are:
So the previous example works this way:
GET /api/test
are found./all/ocelot
matches, because the first one is only forPOST
./all/ocelot
is created andGET
method is added to it.POST /api/test
are found.POST
, second one is for all methods./all/ocelot/
is already created, soPOST
method is added to it./post/ocelot
is created andPOST
method is added to it.