Skip to content

A simple rate limiter for Asp.Net Core APIs projects.

Notifications You must be signed in to change notification settings

farhadzm/ApiRateLimiter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ApiRateLimiter

A simple rate limiter for Asp.Net Core APIs projects.

Usage:

Register AddApiRateLimiter in ConfigureServices.

public void ConfigureServices(IServiceCollection services)
{
    services.AddApiRateLimiter(Configuration);
    services.AddInMemoryRateLimiter();
}

And adding UseRateLimiter middleware.

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    app.UseRateLimiter();
}

appsettings.json file:

"ApiRateLimiterOption": {
  "ApiUrls": {
    "/api/values": {
      "limit": 2,
      "duration": 5
    },
    "/api/values/{everyThing}": {
      "limit": 5,
      "duration": 10
    }
  },
  "WhiteList": [
      "127.0.0.1"
  ]
}

About

A simple rate limiter for Asp.Net Core APIs projects.

Resources

Stars

Watchers

Forks

Languages