Adding RateLimit Feature ...

This commit is contained in:
2026-11-09 15:40:10 +03:30
parent 0a8f9692dd
commit cba7637255
17 changed files with 787 additions and 10 deletions
+26
View File
@@ -0,0 +1,26 @@
using xCommons.Constants;
using System.Collections.Generic;
namespace xCommons.Configurations
{
public class XRateLimitConfiguration
{
public bool Enabled { get; set; } = false;
public int StatusCode { get; set; } = 429;
public int DefaultLimit { get; set; } = 60;
public int DefaultPeriodSeconds { get; set; } = 60;
public bool ApplyToAllRoutes { get; set; } = false;
public ICollection<XRateLimitRule> Rules { get; set; } = [];
public XRateLimitKeyMode DefaultKeyMode { get; set; } = XRateLimitKeyMode.Ip;
}
public partial class XRateLimitRule
{
public int Limit { get; set; } = 60;
public bool Enabled { get; set; } = true;
public int PeriodSeconds { get; set; } = 60;
public string PathPrefix { get; set; } = "/";
public string Name { get; set; } = string.Empty;
public XRateLimitKeyMode KeyMode { get; set; } = XRateLimitKeyMode.Ip;
}
}