| | | 1 | | namespace ProjectTemplate.Web.Options; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Represents template-level rate limiting configuration. |
| | | 5 | | /// </summary> |
| | | 6 | | public sealed class ApplicationRateLimitingOptions |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Configuration section name for rate limiting settings. |
| | | 10 | | /// </summary> |
| | | 11 | | public const string SectionName = "ProjectTemplate:RateLimiting"; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Gets or sets a value indicating whether rate limiting is enabled. |
| | | 15 | | /// </summary> |
| | 1428 | 16 | | public bool Enabled { get; set; } = true; |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Gets or sets a value indicating whether to use the global limiter. |
| | | 20 | | /// When true, <see cref="GlobalFixedWindow"/> is used as a global limiter. |
| | | 21 | | /// </summary> |
| | 1432 | 22 | | public bool UseGlobalLimiter { get; set; } = true; |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// Gets or sets the global fixed-window rate limiting options. |
| | | 26 | | /// </summary> |
| | 3472 | 27 | | public FixedWindowRateLimitingOptions GlobalFixedWindow { get; set; } = new() |
| | 520 | 28 | | { |
| | 520 | 29 | | PermitLimit = 60, |
| | 520 | 30 | | WindowSeconds = 60, |
| | 520 | 31 | | QueueLimit = 0 |
| | 520 | 32 | | }; |
| | | 33 | | |
| | | 34 | | /// <summary> |
| | | 35 | | /// Gets or sets the fixed-window rate limiting options applied at the template level. |
| | | 36 | | /// </summary> |
| | 3388 | 37 | | public FixedWindowRateLimitingOptions FixedWindowPolicy { get; set; } = new() |
| | 520 | 38 | | { |
| | 520 | 39 | | PermitLimit = 60, |
| | 520 | 40 | | WindowSeconds = 60, |
| | 520 | 41 | | QueueLimit = 0 |
| | 520 | 42 | | }; |
| | | 43 | | |
| | | 44 | | /// <summary> |
| | | 45 | | /// Gets or sets the concurrency-based rate limiting options applied at the template level. |
| | | 46 | | /// </summary> |
| | 2606 | 47 | | public ConcurrencyRateLimitingOptions ConcurrencyPolicy { get; set; } = new() |
| | 520 | 48 | | { |
| | 520 | 49 | | PermitLimit = 10, |
| | 520 | 50 | | QueueLimit = 0 |
| | 520 | 51 | | }; |
| | | 52 | | } |