Skip to content

BerkayMehmetSert/netCore.RateLimiting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

.Net Core RateLimiting Example

Description

This project is a .NET Core application that demonstrates how to implement rate limiting for RESTful APIs using the AspNetCoreRateLimit library.

Prerequisites

To run this project, you will need the following:

Running the Project

To run the project, follow these steps:

  1. Clone the repository to your local machine.
git clone https://github.com/BerkayMehmetSert/netCore.RateLimiting.git
  1. Open the project in your IDE of choice.

  2. Run the project.

dotnet run

Configuring Rate Limiting

The rate limiting settings for the API are defined in the appsettings.json file. You can change the settings to suit your needs. The settings include:

  • EnableEndpointRateLimiting: Whether or not to enable rate limiting for endpoints.
  • StackBlockedRequests: Whether or not to stack blocked requests and process them later.
  • RealIpHeader: The header name that contains the client's real IP address.
  • ClientIdHeader: The header name that contains the client ID.
  • HttpStatusCode: The HTTP status code to return when a client is blocked.
  • GeneralRules: A list of rules that apply to all endpoints. Each rule has the following properties:
    • Endpoint: The endpoint pattern (e.g. /api/customers/*).
    • Period: The time period for the rule (e.g. 1m for 1 minute).
    • Limit: The maximum number of requests allowed during the period.

Usage

The API has the following endpoints:

  • POST /api/customers: Creates a new customer.
  • PUT /api/customers/{id}: Updates an existing customer.
  • DELETE /api/customers/{id}: Deletes an existing customer.
  • GET /api/customers/{id}: Retrieves an existing customer by ID.
  • GET /api/customers: Retrieves a list of all customers.

Each endpoint is rate-limited according to the rules defined in the appsettings.json file.

About

This project is a .NET Core application that demonstrates how to implement rate limiting for RESTful APIs using the AspNetCoreRateLimit library.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages