twerner / ASP.NET Core Rate Limiting
0 gustos
0 bifurcaciones
2 archivos
Última actividad 1 year ago
| 1 | // Existing services ... |
| 2 | |
| 3 | builder.Services.AddRateLimiter(options => |
| 4 | { |
| 5 | options.GlobalLimiter = PartitionedRateLimiter.Create<HttpContext, string>(httpContext => |
| 6 | RateLimitPartition.GetFixedWindowLimiter( |
| 7 | partitionKey: httpContext.User.Identity?.Name ?? httpContext.Request.Headers.Host.ToString(), |
| 8 | factory: partition => new FixedWindowRateLimiterOptions |
| 9 | { |
| 10 | AutoReplenishment = true, |
Siguiente
Anterior