RateLimit.Core
1.0.2
dotnet add package RateLimit.Core --version 1.0.2
NuGet\Install-Package RateLimit.Core -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RateLimit.Core" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RateLimit.Core --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RateLimit.Core, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install RateLimit.Core as a Cake Addin #addin nuget:?package=RateLimit.Core&version=1.0.2 // Install RateLimit.Core as a Cake Tool #tool nuget:?package=RateLimit.Core&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Author: Khoi Tran
Package: RateLimit.Core
The .NET package provides a middleware service to protect your application by limit the request rate.
If an IpAddress
have number of request cross over the MaxRequestPerPeriod
then it will be block by returning a TooManyRequest(429)
in a mount of time (config by BlockTime
in second)
Installation
nuget install RateLimit.Core
Usage
- appsetting.json:
"RateLimit": {
"CacheProvider": {
"Redis": {
"Host": "localhost:6379",
"Database": 0,
"ConnectTimeout": 4, // int: second
"CacheTime": 3200 // int: second
},
"Memory": {
"CacheTime": 3200 // int: second
}
},
"PeriodTime": 10,
"MaxRequestPerPeriod": 1,
"BlockTime": 10,
"Requests": [
{
"EndPoint": "/api/controller/end-point-1",
"HeaderKey": ""
},
{
"EndPoint": "/api/controller/end-point-2",
"HeaderKey": "ServiceId"
},
{
"EndPoint": "/api/controller/end-point-2",
"HeaderKey": "ServiceId"
}
]
}
- Startup.cs:
using RateLimit.Core;
using RateLimit.Core.Configs;
namespace WebApplication2
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
// ...
services.AddRateLimit(Configuration, CacheType.Redis); // default is CacheType.Memory
// ...
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
// ...
app.UseRateLimitMiddleware();
// ...
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 3.1
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Caching.Abstractions (>= 3.1.31)
- Microsoft.Extensions.Caching.Memory (>= 3.1.31)
- Microsoft.Extensions.Configuration.Abstractions (>= 3.1.31)
- Microsoft.Extensions.Configuration.Binder (>= 3.1.31)
- Microsoft.Extensions.Options (>= 3.1.31)
- Newtonsoft.Json (>= 13.0.2)
- StackExchange.Redis (>= 2.0.519)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Add README.md