Class ThrottleAttribute
rate limit requests to this endpoint based on a request http header sent by the client.
Inheritance
Inherited Members
Namespace: FastEndpoints
Assembly: FastEndpoints.Attributes.dll
Syntax
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public class ThrottleAttribute : Attribute
Constructors
ThrottleAttribute(Int32, Double, String)
rate limit requests to this endpoint based on a request http header sent by the client.
Declaration
public ThrottleAttribute(int hitLimit, double durationSeconds, string headerName = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | hitLimit | how many requests are allowed within the given duration |
System.Double | durationSeconds | the frequency in seconds where the accrued hit count should be reset |
System.String | headerName | the name of the request header used to uniquely identify clients.
header name can also be configured globally using |
Properties
DurationSeconds
the frequency in seconds where the accrued hit count should be reset
Declaration
public double DurationSeconds { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
HeaderName
the name of the request header used to uniquely identify clients.
header name can also be configured globally using app.UseFastEndpoints(c=> c.Throttle...)
not specifying a header name will first look for 'X-Forwarded-For' header and if not present, will use HttpContext.Connection.RemoteIpAddress
.
Declaration
public string HeaderName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
HitLimit
how many requests are allowed within the given duration
Declaration
public int HitLimit { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |