Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit ea222ba

Browse files
committed
Added XML comments
1 parent a5290f7 commit ea222ba

6 files changed

+26
-2
lines changed

WebApiThrottle/IThrottleRepository.cs

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
namespace WebApiThrottle
88
{
9+
/// <summary>
10+
/// Implement this interface if you want to create a persistent store for the throttle metrics
11+
/// </summary>
912
public interface IThrottleRepository
1013
{
1114
bool Any(string id);

WebApiThrottle/RequestIndentity.cs

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
namespace WebApiThrottle
88
{
9+
/// <summary>
10+
/// Stores the client ip, key and endpoint
11+
/// </summary>
912
public class RequestIndentity
1013
{
1114
public string ClientIp { get; set; }

WebApiThrottle/ThrottleCounter.cs

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
namespace WebApiThrottle
88
{
9+
/// <summary>
10+
/// Stores the initial access time and the numbers of calls made from that point
11+
/// </summary>
912
public class ThrottleCounter
1013
{
1114
public DateTime Timestamp { get; set; }

WebApiThrottle/ThrottlePolicy.cs

+15
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,36 @@
66

77
namespace WebApiThrottle
88
{
9+
/// <summary>
10+
/// Rate limits policy
11+
/// </summary>
912
public class ThrottlePolicy
1013
{
14+
/// <summary>
15+
/// Enables IP throttling
16+
/// </summary>
1117
public bool IpThrottling { get; set; }
1218
public List<string> IpWhitelist { get; set; }
1319
public Dictionary<string, RateLimits> IpRules { get; set; }
1420

21+
/// <summary>
22+
/// Enables Cient Key throttling
23+
/// </summary>
1524
public bool ClientThrottling { get; set; }
1625
public List<string> ClientWhitelist { get; set; }
1726
public Dictionary<string, RateLimits> ClientRules { get; set; }
1827

28+
/// <summary>
29+
/// Enables routes throttling
30+
/// </summary>
1931
public bool EndpointThrottling { get; set; }
2032
public List<string> EndpointWhitelist { get; set; }
2133

2234
internal Dictionary<RateLimitPeriod, long> Rates { get; set; }
2335

36+
/// <summary>
37+
/// Configure default request limits per second, minute, hour or day
38+
/// </summary>
2439
public ThrottlePolicy(long? perSecond, long? perMinute = null, long? perHour = null, long? perDay = null)
2540
{
2641
Rates = new Dictionary<RateLimitPeriod, long>();

WebApiThrottle/ThrottlingHandler.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques
6161
//check limit
6262
if (rateLimit > 0 && throttleCounter.TotalRequests > rateLimit)
6363
{
64-
var id = identity.ToString() + "-" + rateLimitPeriod;
65-
return QuotaExceededResponse(request, string.Format("API calls quota exceeded! maximum admitted {0} per {1} ID {2}", rateLimit, rateLimitPeriod, id));
64+
return QuotaExceededResponse(request, string.Format("API calls quota exceeded! maximum admitted {0} per {1}", rateLimit, rateLimitPeriod));
6665
}
6766
}
6867
}

WebApiThrottle/WebApiThrottle.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<DefineConstants>TRACE</DefineConstants>
3131
<ErrorReport>prompt</ErrorReport>
3232
<WarningLevel>4</WarningLevel>
33+
<DocumentationFile>bin\Release\WebApiThrottle.XML</DocumentationFile>
3334
</PropertyGroup>
3435
<ItemGroup>
3536
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">

0 commit comments

Comments
 (0)