diff --git a/lib/src/rate_limiter.dart b/lib/src/rate_limiter.dart index 3c4bc450..a14af9f9 100644 --- a/lib/src/rate_limiter.dart +++ b/lib/src/rate_limiter.dart @@ -30,8 +30,19 @@ abstract class RateLimiter { /// Updates the underlying store with information about the new /// [window] that the user is operating in. - FutureOr updateCurrentWindow(RequestContext req, ResponseContext res, - RateLimitingWindow window); + FutureOr updateCurrentWindow( + RequestContext req, ResponseContext res, RateLimitingWindow window); + + /// Computes the amount of points that a given request will cost. This amount + /// is then added to the amount of points that the user has already consumed + /// in the current [window]. + /// + /// The default behavior is to return `1`, which signifies that all requests + /// carry the same weight. + FutureOr getEndpointCost(RequestContext req, ResponseContext res, + RateLimitingWindow window) { + return Future.value(1); + } FutureOr denyRequest(RequestContext req, ResponseContext res, RateLimitingWindow window) {}