Class ThrottleAttribute
rate limit requests to this endpoint based on a request http header sent by the client.
Inherited Members
Namespace: FastEndpoints
Assembly: FastEndpoints.Attributes.dll
Syntax
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public sealed class ThrottleAttribute : Attribute
Constructors
ThrottleAttribute(int, 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 |
---|---|---|
int | hitLimit | how many requests are allowed within the given duration |
double | durationSeconds | the frequency in seconds where the accrued hit count should be reset |
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 |
---|---|
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 |
---|---|
string |
HitLimit
how many requests are allowed within the given duration
Declaration
public int HitLimit { get; set; }
Property Value
Type | Description |
---|---|
int |