diff --git a/Program.cs b/Program.cs index 9527f99..ea89877 100644 --- a/Program.cs +++ b/Program.cs @@ -6,27 +6,36 @@ using Ocelot.Middleware; var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger(); logger.Info("Logging initialized."); -var builder = WebApplication.CreateBuilder(args); - -// Make sure to add the Ocelot configuration file -var suffix = builder.Environment.IsDevelopment() ? ".Development" : ""; -builder.Configuration.AddJsonFile($"ocelot{suffix}.json"); - -// Add Ocelot services -builder.Services.AddOcelot(); - -var app = builder.Build(); - -app.UseHttpsRedirection(); -app.UseRouting(); -app.UseAuthorization(); - -// Use Ocelot middleware in an appropriate way -app.UseEndpoints(endpoints => +try { - endpoints.MapControllers(); -}); + var builder = WebApplication.CreateBuilder(args); -app.UseOcelot().Wait(); + // Make sure to add the Ocelot configuration file + var suffix = builder.Environment.IsDevelopment() ? ".Development" : ""; + builder.Configuration.AddJsonFile($"ocelot{suffix}.json"); -app.Run(); + // Add Ocelot services + builder.Services.AddOcelot(); + + var app = builder.Build(); + + app.UseHttpsRedirection(); + app.UseRouting(); + app.UseAuthorization(); + + // Use Ocelot middleware in an appropriate way + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + + app.UseOcelot().Wait(); + + app.Run(); + +} +catch(Exception ex) +{ + logger.Error(ex, "Stopped program because of exception."); + throw; +} \ No newline at end of file