Skip to content

Changed the Rate Limiter API to action-based #41657

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

Closed
wants to merge 3 commits into from

Conversation

Elfocrash
Copy link
Contributor

@Elfocrash Elfocrash commented May 12, 2022

Changed the Rate Limiter API to action-based

Description

The most common approach when it comes to configuring options/settings in AddXXX, UseXXX and MapXXX methods during project setup is to use the Action-based approach.
UseRateLimiter doesn't follow that approach. This PR addresses that by allowing people to do:

app.UseRateLimiter(options =>
{
    options.DefaultRejectionStatusCode = 429;
});

Fixes #41655

@ghost ghost added area-runtime community-contribution Indicates that the PR has been added by a community member labels May 12, 2022
@@ -29,11 +29,14 @@ public static IApplicationBuilder UseRateLimiter(this IApplicationBuilder app)
/// <param name="app"></param>
/// <param name="options"></param>
/// <returns></returns>
public static IApplicationBuilder UseRateLimiter(this IApplicationBuilder app, RateLimiterOptions options)
public static IApplicationBuilder UseRateLimiter(this IApplicationBuilder app, Action<RateLimiterOptions> options)
Copy link
Member

Choose a reason for hiding this comment

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

This'd probably be called configure now rather than options, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I missed this. configure seems to be the common naming convention for this so I'll change it. Currently pending on some back and forth in #41655 regarding whether this overload is needed or not. Once that's settled I'll update it with the latest changes

@adityamandaleeka
Copy link
Member

@Elfocrash Thanks for submitting this issue and PR. Based on the discussion in #41655 it looks like we should wait for #41667 which will make this middleware endpoint-aware.

Once that's done, we'll have an API where this type of action will fit in. For now, I think we should close this PR.

@amcasey amcasey added area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares and removed area-runtime labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UseRateLimiter API deviates by the Action-based config approach
5 participants