Updated
This commit is contained in:
parent
bedd41f829
commit
d2ac9710f0
|
@ -0,0 +1 @@
|
||||||
|
nummer4=TEST
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="EonaCat.Env">
|
<Reference Include="EonaCat.Env">
|
||||||
<HintPath>..\..\..\EonaCat.Env\EonaCat.Env\bin\Debug\netstandard2.1\EonaCat.Env.dll</HintPath>
|
<HintPath>..\..\..\EonaCat.Env\EonaCat.Env\bin\Debug\net6.0\EonaCat.Env.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,32 @@
|
||||||
// See https://aka.ms/new-console-template for more information
|
// See https://aka.ms/new-console-template for more information
|
||||||
using EonaCat.Env;
|
using EonaCat.Env;
|
||||||
using EonaCat.Env.Helpers;
|
using EonaCat.Env.Helpers;
|
||||||
|
using System.Diagnostics.Metrics;
|
||||||
|
|
||||||
Console.WriteLine("Hello, World!");
|
Console.WriteLine("Hello, World!");
|
||||||
Env.LoadIntoEnvironment();
|
Env.LoadIntoEnvironment(new Settings(traverseDirectories:true));
|
||||||
var test = Env.Read(new Settings(traverseDirectories:true));
|
var test = Env.Read(new Settings(traverseDirectories:true));
|
||||||
Getter.SwallowExceptions = false;
|
Getter.SwallowExceptions = false;
|
||||||
Console.WriteLine(Environment.GetEnvironmentVariable("nummer4"));
|
if (test.Any())
|
||||||
Console.WriteLine(Getter.GetString("nummer4"));
|
Console.WriteLine("From Env.Read: " + test.Values);
|
||||||
|
Console.WriteLine("From Environment variable: " + Environment.GetEnvironmentVariable("nummer4"));
|
||||||
|
Console.WriteLine("From Getter: " + Getter.GetValue<string>("nummer4"));
|
||||||
|
Console.WriteLine("From SecretManager class: " + Secrets.API_KEY);
|
||||||
Console.WriteLine("+------+");
|
Console.WriteLine("+------+");
|
||||||
Console.WriteLine(Environment.GetEnvironmentVariable("FAAL"));
|
Console.WriteLine(Environment.GetEnvironmentVariable("FAAL"));
|
||||||
Console.WriteLine("test");
|
Console.WriteLine("test");
|
||||||
|
|
||||||
|
public static class Secrets
|
||||||
|
{
|
||||||
|
static Secrets()
|
||||||
|
{
|
||||||
|
Env.LoadIntoEnvironment(new Settings(traverseDirectories: true));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string API_KEY => GetApiKey();
|
||||||
|
|
||||||
|
private static string GetApiKey()
|
||||||
|
{
|
||||||
|
return Getter.GetValue<string>("nummer4");
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="EonaCat.Logger" Version="1.0.4" />
|
||||||
<PackageReference Include="EonaCat.Web.Tracer" Version="1.0.0" />
|
<PackageReference Include="EonaCat.Web.Tracer" Version="1.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
|
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -15,10 +16,4 @@
|
||||||
<ProjectReference Include="..\..\..\EonaCat.Web.RateLimiter\EonaCat.Web.RateLimiter\EonaCat.Web.RateLimiter.csproj" />
|
<ProjectReference Include="..\..\..\EonaCat.Web.RateLimiter\EonaCat.Web.RateLimiter\EonaCat.Web.RateLimiter.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="EonaCat.Logger">
|
|
||||||
<HintPath>..\..\..\EonaCat.Logger\EonaCat.Logger\bin\Debug\netstandard2.0\EonaCat.Logger.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
using EonaCat.Logger;
|
||||||
|
using EonaCat.Logger.Extensions;
|
||||||
using EonaCat.Logger.Managers;
|
using EonaCat.Logger.Managers;
|
||||||
using EonaCat.Web.RateLimiter;
|
using EonaCat.Web.RateLimiter;
|
||||||
using EonaCat.Web.RateLimiter.Endpoints.Extensions;
|
using EonaCat.Web.RateLimiter.Endpoints.Extensions;
|
||||||
|
@ -7,10 +9,10 @@ using Microsoft.AspNetCore.Builder;
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
//FileLoggerOptions options = new FileLoggerOptions();
|
FileLoggerOptions options = new FileLoggerOptions();
|
||||||
//options.MaxRolloverFiles = 5;
|
options.MaxRolloverFiles = 5;
|
||||||
//options.FileSizeLimit = 1 * 1024 * 1024 / 4;
|
options.FileSizeLimit = 1 * 1024 * 1024 / 4;
|
||||||
//builder.Logging.AddEonaCatFileLogger(fileLoggerOptions: options, filenamePrefix:"web");
|
builder.Logging.AddEonaCatFileLogger(fileLoggerOptions: options, filenamePrefix:"web");
|
||||||
|
|
||||||
builder.Services.AddRazorPages();
|
builder.Services.AddRazorPages();
|
||||||
|
|
||||||
|
@ -21,12 +23,12 @@ builder.Services.AddRazorPages();
|
||||||
//};
|
//};
|
||||||
|
|
||||||
//builder.Services.AddRateLimiting(rateLimitOptions);
|
//builder.Services.AddRateLimiting(rateLimitOptions);
|
||||||
var options = new RateLimiterOptions();
|
var rateOptions = new RateLimiterOptions();
|
||||||
options.OutputLimitMessageAsHtml = false;
|
rateOptions.OutputLimitMessageAsHtml = false;
|
||||||
options.OutputLimitMessageAsXml = false;
|
rateOptions.OutputLimitMessageAsXml = false;
|
||||||
options.OutputLimitMessageAsJson = true;
|
rateOptions.OutputLimitMessageAsJson = true;
|
||||||
|
|
||||||
options.AddDefaultConfiguration(config =>
|
rateOptions.AddDefaultConfiguration(config =>
|
||||||
config.AddIpResolver().AddRule(3, TimeSpan.FromSeconds(10))
|
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");
|
await httpContext.Response.WriteAsync(" THIS IS MY CUSTOM RATE LIMIT MESSAGE");
|
||||||
}
|
}
|
||||||
|
|
||||||
//builder.Services.UseWebRateLimiter(options);
|
//builder.Services.UseWebRateLimiter(rateOptions);
|
||||||
builder.Services.UseWebRateLimiter(options);
|
builder.Services.UseWebRateLimiter(rateOptions);
|
||||||
builder.Services.UseWebRateLimiter(options =>
|
builder.Services.UseWebRateLimiter(rateOptions =>
|
||||||
{
|
{
|
||||||
// Configures the default rateLimitConfiguration
|
// Configures the default rateLimitConfiguration
|
||||||
options.AddDefaultConfiguration(rateLimitConfiguration =>
|
rateOptions.AddDefaultConfiguration(rateLimitConfiguration =>
|
||||||
{
|
{
|
||||||
// throttling is based on request ip
|
// throttling is based on request ip
|
||||||
rateLimitConfiguration.AddIpResolver()
|
rateLimitConfiguration.AddIpResolver()
|
||||||
|
|
Loading…
Reference in New Issue