getEndpointCost method

FutureOr<int> getEndpointCost(
  1. RequestContext req,
  2. ResponseContext res,
  3. RateLimitingWindow<User> 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.

Implementation

FutureOr<int> getEndpointCost(RequestContext req, ResponseContext res,
    RateLimitingWindow<User> window) {
  return Future<int>.value(1);
}