Exemplo n.º 1
0
 static Func<IHttpRequest, Task<HttpResponse>> Wrap(Func<IHttpRequest, Task<HttpResponse>> handler, LeakyBucket rateLimitBucket)
 {
     return request => rateLimitBucket.Fill(1) ? handler(request) : Task.FromResult(TooManyRequests);
 }
Exemplo n.º 2
0
 RateLimitedEndpoint(Method method, Route route, Func<IHttpRequest, Task<HttpResponse>> handler, LeakyBucket rateLimitBucket)
     : base(method, route, Wrap(handler, rateLimitBucket))
 {
     this.rateLimitBucket = rateLimitBucket;
 }