Init rate limiter
This commit is contained in:
parent
3bab3b2d57
commit
f738a6016b
1 changed files with 14 additions and 0 deletions
14
lib/src/rate_limiter.dart
Normal file
14
lib/src/rate_limiter.dart
Normal file
|
@ -0,0 +1,14 @@
|
|||
import 'package:angel_framework/angel_framework.dart';
|
||||
|
||||
/// A base class that facilitates rate limiting API's or endpoints,
|
||||
/// typically to prevent spam and abuse.
|
||||
abstract class RateLimiter {
|
||||
/// The maximum number of requests allowed within the given [window].
|
||||
final int maxRequestsPerWindow;
|
||||
|
||||
/// The amount of time, during which, a user is not allowed to send
|
||||
/// more than [maxRequestsPerWindow].
|
||||
final Duration window;
|
||||
|
||||
RateLimiter(this.maxRequestsPerWindow, this.window);
|
||||
}
|
Loading…
Reference in a new issue