From 24858e50b7fde02d4eebb72fed84fa031804c952 Mon Sep 17 00:00:00 2001 From: Tarun Jain Date: Tue, 25 Apr 2023 01:54:48 +0530 Subject: [PATCH] formatting program.cs --- .../Web.Bff.Shopping/aggregator/Program.cs | 54 +++++++++++-------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs index 9fd652704..2583d85a4 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs @@ -1,8 +1,10 @@ -var appName = "Ordering.API"; +var appName = "Ordering.API"; var builder = WebApplication.CreateBuilder(args); -builder.WebHost.ConfigureAppConfiguration(cb => { +builder.WebHost.ConfigureAppConfiguration(cb => +{ var sources = cb.Sources; - sources.Insert(3, new Microsoft.Extensions.Configuration.Json.JsonConfigurationSource() { + sources.Insert(3, new Microsoft.Extensions.Configuration.Json.JsonConfigurationSource() + { Optional = true, Path = "appsettings.localhost.json", ReloadOnChange = false @@ -22,14 +24,17 @@ builder.Services.AddCustomMvc(builder.Configuration) .AddApplicationServices() .AddGrpcServices(); var app = builder.Build(); -if (app.Environment.IsDevelopment()) { +if (app.Environment.IsDevelopment()) +{ app.UseDeveloperExceptionPage(); } -else { +else +{ app.UseExceptionHandler("/Home/Error"); } var pathBase = builder.Configuration["PATH_BASE"]; -if (!string.IsNullOrEmpty(pathBase)) { +if (!string.IsNullOrEmpty(pathBase)) +{ app.UsePathBase(pathBase); } @@ -51,32 +56,36 @@ app.UseAuthentication(); app.UseAuthorization(); app.MapDefaultControllerRoute(); - app.MapControllers(); - app.MapHealthChecks("/hc", new HealthCheckOptions() { - Predicate = _ => true, - ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse - }); - app.MapHealthChecks("/liveness", new HealthCheckOptions { - Predicate = r => r.Name.Contains("self") - }); +app.MapControllers(); +app.MapHealthChecks("/hc", new HealthCheckOptions() +{ + Predicate = _ => true, + ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse +}); +app.MapHealthChecks("/liveness", new HealthCheckOptions +{ + Predicate = r => r.Name.Contains("self") +}); -try { - +try +{ Log.Information("Starts Web Application ({ApplicationContext})...", Program.AppName); await app.RunAsync(); return 0; } -catch (Exception ex) { +catch (Exception ex) +{ Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", Program.AppName); return 1; } -finally { +finally +{ Log.CloseAndFlush(); } - -Serilog.ILogger CreateSerilogLogger(IConfiguration configuration) { +Serilog.ILogger CreateSerilogLogger(IConfiguration configuration) +{ var seqServerUrl = configuration["Serilog:SeqServerUrl"]; var logstashUrl = configuration["Serilog:LogstashgUrl"]; return new LoggerConfiguration() @@ -89,7 +98,8 @@ Serilog.ILogger CreateSerilogLogger(IConfiguration configuration) { .ReadFrom.Configuration(configuration) .CreateLogger(); } -public partial class Program { +public partial class Program +{ public static string Namespace = typeof(Program).Assembly.GetName().Name; public static string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1); @@ -212,4 +222,4 @@ public static class ServiceCollectionExtensions return services; } -} \ No newline at end of file +}