Skip to content
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

Add support for other HTTP verbs for aggregation aka UpstreamHttpMethod enhancements #1389

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

crb02005
Copy link

@crb02005 crb02005 commented Dec 7, 2020

This changes the FileAggregateRoute to allow other verbs.
It is for consumers not following traditional REST. Several APIs do not follow the REST guidelines and may use POST for getting data. In cases like these being able to specify a verb is helpful.

stefancruz added a commit to stefancruz/Ocelot that referenced this pull request Dec 23, 2022
@raman-m
Copy link
Member

raman-m commented Jul 15, 2023

Hi Carl!
Thanks for your interest in Ocelot!

Could you Sync fork please? So, your develop branch is outdated!

@raman-m raman-m self-requested a review July 15, 2023 10:51
@raman-m raman-m added proposal Proposal for a new functionality in Ocelot needs feedback Issue is waiting on feedback before acceptance labels Jul 15, 2023
Copy link
Member

@raman-m raman-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything is OK.
But we have to write a few acceptance tests which will cover added logic.

Could you write at least one acceptance test please?

src/Ocelot/Configuration/File/FileAggregateRoute.cs Outdated Show resolved Hide resolved
Comment on lines 26 to 32
private Route SetUpAggregateRoute(IEnumerable<Route> routes, FileAggregateRoute aggregateRoute, FileGlobalConfiguration globalConfiguration)
{
if (!aggregateRoute.UpstreamHttpMethod.Any())
{
// Default method to Get for standard use case
aggregateRoute.UpstreamHttpMethod.Add(HttpMethod.Get.ToString());
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to unit test this code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HttpMethod.Get.ToString() should be a static field of class

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And what's the goal of having static field, Raynald?
I have another alternative which is static too → HttpMethods.Get in the Microsoft.AspNetCore.Http namespace 😉
This is fixed in commit 02a3d99 ✔️

Copy link
Member

@raman-m raman-m Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RaynaldM, I've implemented your concept of a single global setting aka "static field". The commit is 98083a1. However, this setting can only be overridden in the C# code; there's no corresponding JSON setting in ocelot.json.
Also, I chose to add the global static property to the FileAggregateRoute class rather than the AggregatesCreator because it appears to be the most appropriate place for its definition.

Copy link
Member

@raman-m raman-m Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit tests commit is 7e07193 ✔️

@raman-m raman-m force-pushed the user/carl-aggregate-methods branch from 5b5bfb0 to 8596743 Compare August 22, 2023 12:02
@raman-m
Copy link
Member

raman-m commented Aug 22, 2023

The feature branch has been rebased onto ThreeMammals:develop!
Welcome to code review!


I see that develop branch in your fork is too old!
Could you Sync fork please? So, develop branch will be updated with top commits!
Could you add me as collaborator to your forked repo please?

Comment on lines 26 to 32
private Route SetUpAggregateRoute(IEnumerable<Route> routes, FileAggregateRoute aggregateRoute, FileGlobalConfiguration globalConfiguration)
{
if (!aggregateRoute.UpstreamHttpMethod.Any())
{
// Default method to Get for standard use case
aggregateRoute.UpstreamHttpMethod.Add(HttpMethod.Get.ToString());
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HttpMethod.Get.ToString() should be a static field of class

@raman-m raman-m added Aggregation Ocelot feature: Request Aggregation and removed needs feedback Issue is waiting on feedback before acceptance labels Nov 6, 2024
Copy link
Member

@raman-m raman-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready for Code Review❕

@@ -218,7 +218,7 @@ Gotchas
-------

* You cannot use Routes with specific **RequestIdKeys** as this would be crazy complicated to track.
* Aggregation only supports the ``GET`` HTTP verb.
* Aggregation supports the ``GET`` HTTP verb for pure REST, it supports other verbs for APIs which do not fully follow REST.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update docs with info about global static DefaultHttpMethod

Comment on lines +656 to +660
[Fact]
[Trait("Feat", "1389")]
public void TODO()
{
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write acceptance tests

@raman-m
Copy link
Member

raman-m commented Nov 6, 2024

@RaynaldM @ggnaegi Greetings team! Your assistance and recommendation are required.
Could you please review the implementation once more?
I have introduced a global static property for the default GET method in the creator's class, but it appears that the feature will remain incomplete without a genuine JSON option. Kindly refer to my comment for Ray's previous code review.

@crb02005 Hi Carl! Are you online?
What are your thoughts on a global JSON setting for the HTTP methods in aggregated routes? This feature would allow us to set desired HTTP verbs at the route level, but what about having one global JSON option?

@raman-m raman-m changed the title Add support for other verbs for aggregation. Add support for other HTTP verbs for aggregation aka UpstreamHttpMethod enhancements Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Aggregation Ocelot feature: Request Aggregation proposal Proposal for a new functionality in Ocelot
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants