Files
KonSoft.Clean/gateways/KonSoft.InternalGateway/Program.cs
2025-10-25 14:44:49 +08:00

39 lines
1.0 KiB
C#

using KonSoft.InternalGateway;
using KonSoft.Shared.Hosting.AspNetCore;
using Serilog;
var assemblyName = typeof(Program).Assembly.GetName().Name!;
SerilogConfigurationHelper.Configure(assemblyName);
try
{
var builder = WebApplication.CreateBuilder(args);
builder.Configuration
.AddAgileConfig(option =>
{
option.ENV = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development";
});
builder.Host
.AddAppSettingsSecretsJson()
.UseAutofac()
.UseSerilog();
builder.Services.AddReverseProxy()
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
await builder.AddApplicationAsync<InternalGatewayModule>();
var app = builder.Build();
await app.InitializeApplicationAsync();
app.MapReverseProxy();
app.MapGet("/heath", () => "Online");
await app.RunAsync();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!");
return 1;
}
finally
{
await Log.CloseAndFlushAsync();
}