C# Class WebApiThrottle.ThrottlingFilter

Throttle action filter
Inheritance: System.Web.Http.Filters.ActionFilterAttribute, IActionFilter
Exibir arquivo Open project: stefanprodan/WebApiThrottle

Public Methods

Method Description
OnActionExecuting ( System.Web.Http.Controllers.HttpActionContext actionContext ) : void
ThrottlingFilter ( ) : System

Initializes a new instance of the ThrottlingFilter class. By default, the QuotaExceededResponseCode property is set to 429 (Too Many Requests).

ThrottlingFilter ( WebApiThrottle.ThrottlePolicy policy, IPolicyRepository policyRepository, IThrottleRepository repository, IThrottleLogger logger, IIpAddressParser ipAddressParser = null ) : System

Initializes a new instance of the ThrottlingFilter class. Persists the policy object in cache using IPolicyRepository implementation. The policy object can be updated by ThrottleManager at runtime.

Protected Methods

Method Description
ComputeThrottleKey ( RequestIdentity requestIdentity, RateLimitPeriod period ) : string
GetClientIp ( HttpRequestMessage request ) : IPAddress
QuotaExceededResponse ( HttpRequestMessage request, object content, HttpStatusCode responseCode, string retryAfter ) : HttpResponseMessage
SetIdentity ( HttpRequestMessage request ) : RequestIdentity

Private Methods

Method Description
ApplyThrottling ( System.Web.Http.Controllers.HttpActionContext filterContext, WebApiThrottle.EnableThrottlingAttribute &attr ) : bool

Method Details

ComputeThrottleKey() protected method

protected ComputeThrottleKey ( RequestIdentity requestIdentity, RateLimitPeriod period ) : string
requestIdentity RequestIdentity
period RateLimitPeriod
return string

GetClientIp() protected method

protected GetClientIp ( HttpRequestMessage request ) : IPAddress
request System.Net.Http.HttpRequestMessage
return System.Net.IPAddress

OnActionExecuting() public method

public OnActionExecuting ( System.Web.Http.Controllers.HttpActionContext actionContext ) : void
actionContext System.Web.Http.Controllers.HttpActionContext
return void

QuotaExceededResponse() protected method

protected QuotaExceededResponse ( HttpRequestMessage request, object content, HttpStatusCode responseCode, string retryAfter ) : HttpResponseMessage
request System.Net.Http.HttpRequestMessage
content object
responseCode HttpStatusCode
retryAfter string
return System.Net.Http.HttpResponseMessage

SetIdentity() protected method

protected SetIdentity ( HttpRequestMessage request ) : RequestIdentity
request System.Net.Http.HttpRequestMessage
return RequestIdentity

ThrottlingFilter() public method

Initializes a new instance of the ThrottlingFilter class. By default, the QuotaExceededResponseCode property is set to 429 (Too Many Requests).
public ThrottlingFilter ( ) : System
return System

ThrottlingFilter() public method

Initializes a new instance of the ThrottlingFilter class. Persists the policy object in cache using IPolicyRepository implementation. The policy object can be updated by ThrottleManager at runtime.
public ThrottlingFilter ( WebApiThrottle.ThrottlePolicy policy, IPolicyRepository policyRepository, IThrottleRepository repository, IThrottleLogger logger, IIpAddressParser ipAddressParser = null ) : System
policy WebApiThrottle.ThrottlePolicy /// The policy. ///
policyRepository IPolicyRepository /// The policy repository. ///
repository IThrottleRepository /// The repository. ///
logger IThrottleLogger /// The logger. ///
ipAddressParser IIpAddressParser /// The ip address provider ///
return System