Skip to content

Commit

Permalink
Endpoint rules example
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprodan committed Dec 9, 2013
1 parent 869ca1b commit bacb2c1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,28 @@ config.MessageHandlers.Add(new ThrottlingHandler()
Repository = new CacheRepository()
});
```
###Endpoint custom rate limits

You can also define custom limits for certain routes, these limits will override the default ones.
You can define endpoint rules by providing relative routes like <code>api/entry/1</code> or just a URL segment like <code>/entry/</code>.
The endpoint throttling engine will search for the expression you've provided in the absolute URI, if the expression is contained in the request route then the rule will be applied.

``` cs
config.MessageHandlers.Add(new ThrottlingHandler()
{
Policy = new ThrottlePolicy(perSecond: 1, perMinute: 20, perHour: 200)
{
IpThrottling = true,
ClientThrottling = true,
EndpointThrottling = true,
EndpointRules = new Dictionary<string, RateLimits>
{
{ "api/search", new RateLimits { PerScond = 10, PerMinute = 100, PerHour = 1000 } }
}
},
Repository = new CacheRepository()
});
```

###Stack rejected requests

Expand Down

0 comments on commit bacb2c1

Please sign in to comment.