Small rate limitting library for rest controllers.
Idea: you can block your endpoints after some requests for specified period of time
- Add a depdendency to your maven project
<dependency>
<groupId>io.github.abondar24</groupId>
<artifactId>SpringRateLimitter</artifactId>
<version>0.0.2-SNAPSHOT</version>
</dependency>
- Import RateConfig to your config or SpringBootApplication
@Import({RateConfig.class})
- Add property controller.package to your applicaiton.yml or application.properties
controller:
package: package-name
-
Add an exception handler for RateLimitException.
-
Annotate controller or separate methods. Number of requests and period im milliseconds can be specified. Defalut values are 1000 requests and 1ms
mvn clean install
- 0.0.1 - basic rate limitter
- 0.0.2 - added check for rate values