Dela via


RateLimiterOptions Class

Definition

Specifies options for the rate limiting middleware.

public sealed class RateLimiterOptions
type RateLimiterOptions = class
Public NotInheritable Class RateLimiterOptions
Inheritance
RateLimiterOptions

Constructors

RateLimiterOptions()

Properties

GlobalLimiter

Gets or sets the global PartitionedRateLimiter<TResource> that will be applied on all requests. The global limiter will be executed first, followed by the endpoint-specific limiter, if one exists.

OnRejected

Gets or sets a Func<T1,T2,TResult> that handles requests rejected by this middleware.

RejectionStatusCode

Gets or sets the default status code to set on the response when a request is rejected. Defaults to Status503ServiceUnavailable.

Methods

AddPolicy<TPartitionKey,TPolicy>(String)

Adds a new rate limiting policy with the given policyName.

AddPolicy<TPartitionKey>(String, Func<HttpContext,RateLimitPartition<TPartitionKey>>)

Adds a new rate limiting policy with the given policyName

AddPolicy<TPartitionKey>(String, IRateLimiterPolicy<TPartitionKey>)

Adds a new rate limiting policy with the given policyName.

Extension Methods

AddConcurrencyLimiter(RateLimiterOptions, String, Action<ConcurrencyLimiterOptions>)

Registers a new ConcurrencyLimiter with the given ConcurrencyLimiterOptions to the application. The limiter can be added to an endpoint via RequireRateLimiting<TBuilder>(TBuilder, String), or via the EnableRateLimitingAttribute.

AddFixedWindowLimiter(RateLimiterOptions, String, Action<FixedWindowRateLimiterOptions>)

Registers a new FixedWindowRateLimiter with the given FixedWindowRateLimiterOptions to the application. The limiter can be added to an endpoint via RequireRateLimiting<TBuilder>(TBuilder, String), or via the EnableRateLimitingAttribute.

AddSlidingWindowLimiter(RateLimiterOptions, String, Action<SlidingWindowRateLimiterOptions>)

Registers a new SlidingWindowRateLimiter with the given SlidingWindowRateLimiterOptions to the application. The limiter can be added to an endpoint via RequireRateLimiting<TBuilder>(TBuilder, String), or via the EnableRateLimitingAttribute.

AddTokenBucketLimiter(RateLimiterOptions, String, Action<TokenBucketRateLimiterOptions>)

Registers a new TokenBucketRateLimiter with the given TokenBucketRateLimiterOptions to the application. The limiter can be added to an endpoint via RequireRateLimiting<TBuilder>(TBuilder, String), or via the EnableRateLimitingAttribute.

Applies to