https://github.com/liteobject/demo.rate.limiting
Rate limiting is the concept of limiting how much a resource can be accessed
https://github.com/liteobject/demo.rate.limiting
api csharp rate-limiting
Last synced: 3 months ago
JSON representation
Rate limiting is the concept of limiting how much a resource can be accessed
- Host: GitHub
- URL: https://github.com/liteobject/demo.rate.limiting
- Owner: LiteObject
- Created: 2022-08-25T02:34:52.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-08-25T02:51:47.000Z (over 3 years ago)
- Last Synced: 2024-12-29T18:23:53.782Z (over 1 year ago)
- Topics: api, csharp, rate-limiting
- Language: C#
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# What is rate limiting?
Rate limiting is the concept of limiting how much a resource can be accessed.
## About this project:
- This is a custom implementation (without worrying too much about algo)
- Rate limiting can be applied to action method using one or more attributes as shown below:
```csharp
[RateLimiter(RateLimitingRule = typeof(RateLimitingRuleForUS), MaxReqCount = 5, TimeSpanInSec = 30)]
[RateLimiter(RateLimitingRule = typeof(RateLimitingRuleForEU))]
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable Get()
{
}
```
- Either max request count within a time range can be specifid from the attribue or it can be configued centrally in the `RateLimitingMiddleware.cs` file.
- In this example, rate limiting rule(s) is picked based on header (token) value. This loggic is within `RulesManager.cs` file.
However, this matching of header value with rule(s) can be easily removed.