-
Notifications
You must be signed in to change notification settings - Fork 10k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
John Luo
committed
May 26, 2021
1 parent
ae286c9
commit 191575d
Showing
12 changed files
with
149 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Threading; | ||
using System.Threading.ResourceLimits; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace Microsoft.AspNetCore.RequestLimiter | ||
{ | ||
internal class HttpContextLimiter : AggregatedResourceLimiter<HttpContext> | ||
{ | ||
private readonly ResourceLimiter _limiter; | ||
|
||
public HttpContextLimiter(ResourceLimiter limiter) | ||
{ | ||
_limiter = limiter; | ||
} | ||
|
||
public override ResourceLease Acquire(HttpContext resourceID, long requestedCount) | ||
{ | ||
return _limiter.Acquire(requestedCount); | ||
} | ||
|
||
public override long EstimatedCount(HttpContext resourceID) | ||
{ | ||
return _limiter.EstimatedCount; | ||
} | ||
|
||
public override ValueTask<ResourceLease> WaitAsync(HttpContext resourceID, long requestedCount, CancellationToken cancellationToken = default) | ||
{ | ||
return _limiter.WaitAsync(requestedCount, cancellationToken); | ||
} | ||
|
||
public static implicit operator HttpContextLimiter(ResourceLimiter limiter) => new HttpContextLimiter(limiter); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
src/Middleware/RequestLimiter/src/RequestLimitRegistration.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.