Class ThrottlingSentinelAttribute
- Namespace
- Cuemon.AspNetCore.Mvc.Filters.Throttling
- Assembly
- Cuemon.AspNetCore.Mvc.dll
Represents an attribute that is used to mark an action method to be protected by a throttling sentinel.
public abstract class ThrottlingSentinelAttribute : ActionFilterAttribute, IActionFilter, IAsyncActionFilter, IResultFilter, IAsyncResultFilter, IOrderedFilter, IFilterFactory, IFilterMetadata- Inheritance
- 
      
      
      
      ThrottlingSentinelAttribute
- Implements
- Inherited Members
Constructors
ThrottlingSentinelAttribute(int, double, TimeUnit)
Initializes a new instance of the ThrottlingSentinelAttribute class.
protected ThrottlingSentinelAttribute(int rateLimit, double window, TimeUnit windowUnit)Parameters
- rateLimitint
- The allowed rate from within a given - window.
- windowdouble
- The duration of the window. 
- windowUnitTimeUnit
- One of the enumeration values that specifies the time unit of - window.
Properties
IsReusable
Gets a value that indicates if the result of CreateInstance(IServiceProvider) can be reused across requests.
public bool IsReusable { get; }Property Value
- bool
- trueif this instance is reusable; otherwise,- false.
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. 
RetryAfterScope
Gets or sets the preferred Retry-After HTTP header value that conforms with RFC 2616.
public RetryConditionScope RetryAfterScope { get; set; }Property Value
- RetryConditionScope
- The preferred Retry-After HTTP header value that conforms with RFC 2616. 
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
- bool
- trueto include a Retry-After HTTP header specifying how long to wait before making a new request; otherwise,- false.
Methods
CreateInstance(IServiceProvider)
Creates an instance of the executable filter.
public IFilterMetadata CreateInstance(IServiceProvider serviceProvider)Parameters
- serviceProviderIServiceProvider
- The request IServiceProvider. 
Returns
- IFilterMetadata
- An instance of the executable filter. 
UniqueContextResolver(HttpContext)
Resolves a unique context of the throttling middleware (eg. IP-address, Authorization header, etc.).
public abstract string UniqueContextResolver(HttpContext context)Parameters
- contextHttpContext
- The HttpContext to extract a unique context from. 
Returns
- string
- A string that uniquely identifies the requester in need of throttling.