1- var appName = "Ordering.API" ;
1+ var appName = "Ordering.API" ;
22var builder = WebApplication . CreateBuilder ( args ) ;
3- builder . WebHost . ConfigureAppConfiguration ( cb => {
3+ builder . WebHost . ConfigureAppConfiguration ( cb =>
4+ {
45 var sources = cb . Sources ;
5- sources . Insert ( 3 , new Microsoft . Extensions . Configuration . Json . JsonConfigurationSource ( ) {
6+ sources . Insert ( 3 , new Microsoft . Extensions . Configuration . Json . JsonConfigurationSource ( )
7+ {
68 Optional = true ,
79 Path = "appsettings.localhost.json" ,
810 ReloadOnChange = false
2224 . AddApplicationServices ( )
2325 . AddGrpcServices ( ) ;
2426var app = builder . Build ( ) ;
25- if ( app . Environment . IsDevelopment ( ) ) {
27+ if ( app . Environment . IsDevelopment ( ) )
28+ {
2629 app . UseDeveloperExceptionPage ( ) ;
2730}
28- else {
31+ else
32+ {
2933 app . UseExceptionHandler ( "/Home/Error" ) ;
3034}
3135var pathBase = builder . Configuration [ "PATH_BASE" ] ;
32- if ( ! string . IsNullOrEmpty ( pathBase ) ) {
36+ if ( ! string . IsNullOrEmpty ( pathBase ) )
37+ {
3338 app . UsePathBase ( pathBase ) ;
3439}
3540
5156app . UseAuthorization ( ) ;
5257
5358app . MapDefaultControllerRoute ( ) ;
54- app . MapControllers ( ) ;
55- app . MapHealthChecks ( "/hc" , new HealthCheckOptions ( ) {
56- Predicate = _ => true ,
57- ResponseWriter = UIResponseWriter . WriteHealthCheckUIResponse
58- } ) ;
59- app . MapHealthChecks ( "/liveness" , new HealthCheckOptions {
60- Predicate = r => r . Name . Contains ( "self" )
61- } ) ;
59+ app . MapControllers ( ) ;
60+ app . MapHealthChecks ( "/hc" , new HealthCheckOptions ( )
61+ {
62+ Predicate = _ => true ,
63+ ResponseWriter = UIResponseWriter . WriteHealthCheckUIResponse
64+ } ) ;
65+ app . MapHealthChecks ( "/liveness" , new HealthCheckOptions
66+ {
67+ Predicate = r => r . Name . Contains ( "self" )
68+ } ) ;
6269
63- try {
64-
70+ try
71+ {
6572 Log . Information ( "Starts Web Application ({ApplicationContext})..." , Program . AppName ) ;
6673 await app . RunAsync ( ) ;
6774
6875 return 0 ;
6976}
70- catch ( Exception ex ) {
77+ catch ( Exception ex )
78+ {
7179 Log . Fatal ( ex , "Program terminated unexpectedly ({ApplicationContext})!" , Program . AppName ) ;
7280 return 1 ;
7381}
74- finally {
82+ finally
83+ {
7584 Log . CloseAndFlush ( ) ;
7685}
7786
78-
79- Serilog . ILogger CreateSerilogLogger ( IConfiguration configuration ) {
87+ Serilog . ILogger CreateSerilogLogger ( IConfiguration configuration )
88+ {
8089 var seqServerUrl = configuration [ "Serilog:SeqServerUrl" ] ;
8190 var logstashUrl = configuration [ "Serilog:LogstashgUrl" ] ;
8291 return new LoggerConfiguration ( )
@@ -89,7 +98,8 @@ Serilog.ILogger CreateSerilogLogger(IConfiguration configuration) {
8998 . ReadFrom . Configuration ( configuration )
9099 . CreateLogger ( ) ;
91100}
92- public partial class Program {
101+ public partial class Program
102+ {
93103
94104 public static string Namespace = typeof ( Program ) . Assembly . GetName ( ) . Name ;
95105 public static string AppName = Namespace . Substring ( Namespace . LastIndexOf ( '.' , Namespace . LastIndexOf ( '.' ) - 1 ) + 1 ) ;
@@ -212,4 +222,4 @@ public static IServiceCollection AddGrpcServices(this IServiceCollection service
212222
213223 return services ;
214224 }
215- }
225+ }
0 commit comments