Class ThrottlingSentinelAttribute
- 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
-
ActionFilterAttributeThrottlingSentinelAttribute
- Implements
-
IActionFilterIAsyncActionFilterIResultFilterIAsyncResultFilterIOrderedFilterIFilterFactoryIFilterMetadata
- Inherited Members
-
ActionFilterAttribute.OnActionExecuting(ActionExecutingContext)ActionFilterAttribute.OnActionExecuted(ActionExecutedContext)ActionFilterAttribute.OnActionExecutionAsync(ActionExecutingContext, ActionExecutionDelegate)ActionFilterAttribute.OnResultExecuting(ResultExecutingContext)ActionFilterAttribute.OnResultExecuted(ResultExecutedContext)ActionFilterAttribute.OnResultExecutionAsync(ResultExecutingContext, ResultExecutionDelegate)ActionFilterAttribute.Order
Constructors
ThrottlingSentinelAttribute(Int32, Double, TimeUnit)
Initializes a new instance of the ThrottlingSentinelAttribute class.
protected ThrottlingSentinelAttribute(int rateLimit, double window, TimeUnit windowUnit)
Parameters
rateLimit
Int32The allowed rate from within a given
window
.window
DoubleThe duration of the window.
windowUnit
TimeUnitOne of the enumeration values that specifies the time unit of
window
.
Properties
IsReusable
Gets a value that indicates if the result of Microsoft.AspNetCore.Mvc.Filters.IFilterFactory.CreateInstance(System.IServiceProvider) can be reused across requests.
public bool IsReusable { get; }
Property Value
- Boolean
true
if 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
- Boolean
true
to 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
serviceProvider
IServiceProviderThe 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
context
HttpContextThe Microsoft.AspNetCore.Http.HttpContext to extract a unique context from.
Returns
- String
A string that uniquely identifies the requester in need of throttling.