Initial import

This commit is contained in:
Stein Helge Riise
2025-11-17 08:32:46 +01:00
commit ede31fbb7e
129 changed files with 9514 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
using minattest_app_host.OpenApi;
using Serilog;
using Yarp.ReverseProxy.Forwarder;
Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.Console()
.CreateBootstrapLogger();
try
{
Log.Information("Starting minattest app host");
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseSerilog((context, services, configuration) => configuration
.ReadFrom.Configuration(context.Configuration)
.ReadFrom.Services(services));
builder.Services.AddReverseProxy()
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwagger();
builder.Services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
var app = builder.Build();
app.UseSerilogRequestLogging();
app.Use((context, next) =>
{
context.Request.Scheme = "https";
return next(context);
});
app.UseAppSwagger();
app.UseHttpsRedirection();
app.MapReverseProxy(configure => configure.Use(async (context, next) =>
{
await next();
var errorFeature = context.GetForwarderErrorFeature();
if (errorFeature is not null && errorFeature.Error != ForwarderError.None && errorFeature.Exception != null)
throw errorFeature.Exception;
}));
app.Run();
}
catch (Exception ex)
{
Log.Fatal(ex, "Application terminated unexpectedly");
}
finally
{
Log.CloseAndFlush();
}