denyRequest implementation

This commit is contained in:
Tobe O 2019-08-14 15:31:42 -04:00
parent 745d07c1a9
commit dead3663f0

View file

@ -81,5 +81,9 @@ abstract class RateLimiter<User> {
/// ///
/// Whatever is returned here will be returned in [handleRequest]. /// Whatever is returned here will be returned in [handleRequest].
FutureOr<Object> denyRequest(RequestContext req, ResponseContext res, FutureOr<Object> denyRequest(RequestContext req, ResponseContext res,
RateLimitingWindow<User> window) {} RateLimitingWindow<User> window, DateTime currentTime) {
var retryAfter = window.resetsAt.difference(currentTime);
res.headers['retry-after'] = retryAfter.inSeconds.toString();
throw AngelHttpException(null, message: errorMessage, statusCode: 429);
}
} }