Update README.md
This commit is contained in:
Родитель
ba8d84cfb2
Коммит
cc9c95382e
22
README.md
22
README.md
|
@ -8,6 +8,26 @@ l_j l_j| _ || / | O |l_j l_jl_j l_j| l___ Y _]| T | | | / |
|
|||
```
|
||||
|
||||
# Throttlebird
|
||||
Throttlebird is a simple Http request throttler to help limit the number of client requests within a given period of time.
|
||||
Throttlebird is a simple http request throttler to help limit the number of client requests within a given period of time.
|
||||
|
||||
[![NuGet version](https://badge.fury.io/nu/Throttlebird.svg)](https://badge.fury.io/nu/Throttlebird) [![Build status](https://ci.appveyor.com/api/projects/status/c2xv4a7fqmfml1qy?svg=true)](https://ci.appveyor.com/project/joelhulen/throttlebird)
|
||||
|
||||
# Example
|
||||
In your WebApiConfig file under the App_Start folder of your ASP.NET MVC project, add the below code block within the Register method:
|
||||
|
||||
```
|
||||
// Implement our custom throttling handler to limit API method calls.
|
||||
// Specify the throttle store, max number of allowed requests within specified timespan,
|
||||
// and message displayed in the error response when exceeded.
|
||||
config.MessageHandlers.Add(new ThrottlingHandler(
|
||||
new InMemoryThrottleStore(),
|
||||
id => 3,
|
||||
TimeSpan.FromSeconds(5),
|
||||
"You have exceeded the maximum number of allowed calls. Please wait until after the cooldown period to try again."
|
||||
));
|
||||
```
|
||||
|
||||
This works across all http requests on your site, limiting the number of requests to 3 every 5 seconds. To adjust, simply modify the *id* parameter to the number of requests, and the timespan to any valid TimeSpan value (FromSeconds, FromMinutes, etc.) to the values that work for you.
|
||||
|
||||
# More to Come
|
||||
This is the the first iteration of this library. Future expansions will allow you to selectively apply throttling on specific controller actions through the use of attributes.
|
||||
|
|
Загрузка…
Ссылка в новой задаче