Updated
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="EonaCat.Logger" Version="1.0.4" />
|
||||
<PackageReference Include="EonaCat.Web.Tracer" Version="1.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
|
||||
</ItemGroup>
|
||||
@@ -15,10 +16,4 @@
|
||||
<ProjectReference Include="..\..\..\EonaCat.Web.RateLimiter\EonaCat.Web.RateLimiter\EonaCat.Web.RateLimiter.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="EonaCat.Logger">
|
||||
<HintPath>..\..\..\EonaCat.Logger\EonaCat.Logger\bin\Debug\netstandard2.0\EonaCat.Logger.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@@ -1,3 +1,5 @@
|
||||
using EonaCat.Logger;
|
||||
using EonaCat.Logger.Extensions;
|
||||
using EonaCat.Logger.Managers;
|
||||
using EonaCat.Web.RateLimiter;
|
||||
using EonaCat.Web.RateLimiter.Endpoints.Extensions;
|
||||
@@ -7,10 +9,10 @@ using Microsoft.AspNetCore.Builder;
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
//FileLoggerOptions options = new FileLoggerOptions();
|
||||
//options.MaxRolloverFiles = 5;
|
||||
//options.FileSizeLimit = 1 * 1024 * 1024 / 4;
|
||||
//builder.Logging.AddEonaCatFileLogger(fileLoggerOptions: options, filenamePrefix:"web");
|
||||
FileLoggerOptions options = new FileLoggerOptions();
|
||||
options.MaxRolloverFiles = 5;
|
||||
options.FileSizeLimit = 1 * 1024 * 1024 / 4;
|
||||
builder.Logging.AddEonaCatFileLogger(fileLoggerOptions: options, filenamePrefix:"web");
|
||||
|
||||
builder.Services.AddRazorPages();
|
||||
|
||||
@@ -21,12 +23,12 @@ builder.Services.AddRazorPages();
|
||||
//};
|
||||
|
||||
//builder.Services.AddRateLimiting(rateLimitOptions);
|
||||
var options = new RateLimiterOptions();
|
||||
options.OutputLimitMessageAsHtml = false;
|
||||
options.OutputLimitMessageAsXml = false;
|
||||
options.OutputLimitMessageAsJson = true;
|
||||
var rateOptions = new RateLimiterOptions();
|
||||
rateOptions.OutputLimitMessageAsHtml = false;
|
||||
rateOptions.OutputLimitMessageAsXml = false;
|
||||
rateOptions.OutputLimitMessageAsJson = true;
|
||||
|
||||
options.AddDefaultConfiguration(config =>
|
||||
rateOptions.AddDefaultConfiguration(config =>
|
||||
config.AddIpResolver().AddRule(3, TimeSpan.FromSeconds(10))
|
||||
);
|
||||
|
||||
@@ -36,12 +38,12 @@ async void RateLimiterMiddleware_OnLimitResponseCreatedAsync(object? sender, Htt
|
||||
await httpContext.Response.WriteAsync(" THIS IS MY CUSTOM RATE LIMIT MESSAGE");
|
||||
}
|
||||
|
||||
//builder.Services.UseWebRateLimiter(options);
|
||||
builder.Services.UseWebRateLimiter(options);
|
||||
builder.Services.UseWebRateLimiter(options =>
|
||||
//builder.Services.UseWebRateLimiter(rateOptions);
|
||||
builder.Services.UseWebRateLimiter(rateOptions);
|
||||
builder.Services.UseWebRateLimiter(rateOptions =>
|
||||
{
|
||||
// Configures the default rateLimitConfiguration
|
||||
options.AddDefaultConfiguration(rateLimitConfiguration =>
|
||||
rateOptions.AddDefaultConfiguration(rateLimitConfiguration =>
|
||||
{
|
||||
// throttling is based on request ip
|
||||
rateLimitConfiguration.AddIpResolver()
|
||||
|
Reference in New Issue
Block a user