Adding RateLimit Feature ...
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user