Class ThrottlingSentinelOptions
- Namespace
- Cuemon.AspNetCore.Http.Throttling
- Assembly
- Cuemon.AspNetCore.dll
Configuration options for ThrottlingSentinelMiddleware.
public class ThrottlingSentinelOptions : IValidatableParameterObject, IParameterObject
- Inheritance
-
ThrottlingSentinelOptions
- Implements
Constructors
ThrottlingSentinelOptions()
Initializes a new instance of the ThrottlingSentinelOptions class.
public ThrottlingSentinelOptions()
Remarks
The following table shows the initial property values for an instance of ThrottlingSentinelOptions.
Property | Initial Value |
---|---|
RateLimitHeaderName | X-RateLimit-Limit |
RateLimitRemainingHeaderName | X-RateLimit-Remaining |
RateLimitResetHeaderName | X-RateLimit-Reset |
RateLimitResetScope | DeltaSeconds |
UseRetryAfterHeader | true |
RetryAfterScope | DeltaSeconds |
TooManyRequestsMessage | Throttling rate limit quota violation. Quota limit exceeded. |
ContextResolver | null |
Quota | null |
ResponseHandler | A HttpResponseMessage initialized to a HTTP status code 429 with zero of one Retry-After header and a body of TooManyRequestsMessage. |
Properties
ContextResolver
Gets or sets the function delegate that will resolve a unique context of the throttling middleware (eg. IP-address, Authorization header, etc.).
public Func<HttpContext, string> ContextResolver { get; set; }
Property Value
- Func<HttpContext, String>
The function delegate that will resolve a unique context of the throttling middleware.
Quota
Gets or sets the allowed quota for a given context.
public ThrottleQuota Quota { get; set; }
Property Value
- ThrottleQuota
The allowed quota for a given context.
RateLimitHeaderName
Gets or sets the name of the rate limit HTTP header.
public string RateLimitHeaderName { get; set; }
Property Value
- String
The name of the rate limit HTTP header.
RateLimitRemainingHeaderName
Gets or sets the name of the rate limit remaining HTTP header.
public string RateLimitRemainingHeaderName { get; set; }
Property Value
- String
The name of the rate limit remaining HTTP header.
RateLimitResetHeaderName
Gets or sets the name of the rate limit reset HTTP header.
public string RateLimitResetHeaderName { get; set; }
Property Value
- String
The name of the rate limit reset HTTP header.
RateLimitResetScope
Gets or sets the preferred rate limit reset HTTP header value that conforms with RFC 7231.
public RetryConditionScope RateLimitResetScope { get; set; }
Property Value
- RetryConditionScope
The preferred rate limit reset HTTP header value that conforms with RFC 7231.
ResponseHandler
Gets or sets the function delegate that configures the response in the form of a HttpResponseMessage.
public Func<TimeSpan, DateTime, HttpResponseMessage> ResponseHandler { get; set; }
Property Value
- Func<TimeSpan, DateTime, HttpResponseMessage>
The function delegate that configures the response in the form of a HttpResponseMessage.
RetryAfterScope
Gets or sets the preferred Retry-After HTTP header value that conforms with RFC 7231.
public RetryConditionScope RetryAfterScope { get; set; }
Property Value
- RetryConditionScope
The preferred Retry-After HTTP header value that conforms with RFC 7231.
TooManyRequestsMessage
Gets or sets the message of a throttled request that has exceeded the rate limit.
public string TooManyRequestsMessage { get; set; }
Property Value
- String
The message of a throttled request that has exceeded the rate limit.
UseRetryAfterHeader
Gets or sets a value indicating whether to include a Retry-After HTTP header specifying how long to wait before making a new request.
public bool UseRetryAfterHeader { get; set; }
Property Value
- Boolean
true
to include a Retry-After HTTP header specifying how long to wait before making a new request; otherwise,false
.
Methods
ValidateOptions()
Determines whether the public read-write properties of this instance are in a valid state.
public void ValidateOptions()
Remarks
This method is expected to throw exceptions when one or more conditions fails to be in a valid state.
Exceptions
- InvalidOperationException
RateLimitHeaderName cannot be null, empty or consist only of white-space characters - or - RateLimitRemainingHeaderName cannot be null, empty or consist only of white-space characters - or - RateLimitResetHeaderName cannot be null, empty or consist only of white-space characters - or - ResponseHandler cannot be null - or - Quota cannot be null when ContextResolver has been specified.