-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Description
Background and Motivation
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.
For example AddControllers uses
public static IMvcBuilder AddControllers(this IServiceCollection services, Action<MvcOptions>? configure){}
not
public static IMvcBuilder AddControllers(this IServiceCollection services, MvcOptions? options){}
Which in return is being invoced with the services.Configure(configure)
method which registers them as Options.
This is pretty standard across most .NET APIs (and libraries).
The UserRateLimiter API is using the object based approach which feels out of place compared to the other ones
public static IApplicationBuilder UseRateLimiter(this IApplicationBuilder app, RateLimiterOptions options)
Proposed API
Instead of providing the object based API, provide an Action based one instead:
public static IApplicationBuilder UseRateLimiter(this IApplicationBuilder app, Action<RateLimiterOptions> configure)
Usage Examples
app.UseRateLimiter(options =>
{
options.DefaultRejectionStatusCode = 429;
});
Risks
We are still in previews so there isn't a breaking change risk.
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels