using Services.Common; var builder = WebApplication.CreateBuilder(args); builder.AddServiceDefaults(); builder.Services.AddGrpc(options => { options.EnableDetailedErrors = true; }); builder.Services.AddControllers(options => { options.Filters.Add(typeof(HttpGlobalExceptionFilter)); options.Filters.Add(typeof(ValidateModelStateFilter)); }); builder.Services.AddRedis(builder.Configuration); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); var app = builder.Build(); app.MapGet("/", () => Results.Redirect("/swagger")); app.UseServiceDefaults(); app.MapGrpcService(); app.MapControllers(); var eventBus = app.Services.GetRequiredService(); eventBus.Subscribe(); eventBus.Subscribe(); try { app.Logger.LogInformation("Configuring web host ({ApplicationContext})...", AppName); app.Logger.LogInformation("Starting web host ({ApplicationContext})...", AppName); await app.RunAsync(); return 0; } catch (Exception ex) { app.Logger.LogCritical(ex, "Program terminated unexpectedly ({ApplicationContext})!", AppName); return 1; } public partial class Program { private static string Namespace = typeof(Program).Assembly.GetName().Name; public static string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1); }