1+
2+ using Microsoft . AspNetCore . Identity ;
13using Microsoft . OpenApi . Models ;
24using ServiceBusMessaging ;
3-
5+ using Serilog ;
46namespace AspNetCoreServiceBusApi1 ;
57
6- public class Startup
8+ internal static class StartupExtensions
79{
8- public Startup ( IConfiguration configuration )
10+ public static WebApplication ConfigureServices ( this WebApplicationBuilder builder )
911 {
10- Configuration = configuration ;
11- }
12+ var services = builder . Services ;
13+ var configuration = builder . Configuration ;
1214
13- public IConfiguration Configuration { get ; }
14-
15- public void ConfigureServices ( IServiceCollection services )
16- {
1715 services . AddControllers ( ) ;
1816
1917 services . AddScoped < ServiceBusSender > ( ) ;
@@ -27,17 +25,21 @@ public void ConfigureServices(IServiceCollection services)
2725 Title = "Payload View API" ,
2826 } ) ;
2927 } ) ;
28+
29+ return builder . Build ( ) ;
3030 }
3131
32- public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
32+ public static WebApplication Configure ( this WebApplication app )
3333 {
34- if ( env . IsDevelopment ( ) )
34+ app . UseSerilogRequestLogging ( ) ;
35+
36+ if ( app . Environment ! . IsDevelopment ( ) )
3537 {
3638 app . UseDeveloperExceptionPage ( ) ;
3739 }
3840 else
3941 {
40- app . UseHsts ( ) ;
42+ app . UseStatusCodePagesWithReExecute ( "~/error" ) ;
4143 }
4244
4345 app . UseStaticFiles ( ) ;
@@ -48,15 +50,14 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
4850 app . UseAuthorization ( ) ;
4951 app . UseCors ( ) ;
5052
51- app . UseEndpoints ( endpoints =>
52- {
53- endpoints . MapControllers ( ) ;
54- } ) ;
53+ app . MapControllers ( ) ;
5554
5655 app . UseSwagger ( ) ;
5756 app . UseSwaggerUI ( c =>
5857 {
5958 c . SwaggerEndpoint ( "/swagger/v1/swagger.json" , "Payload Management API V1" ) ;
6059 } ) ;
60+
61+ return app ;
6162 }
62- }
63+ }
0 commit comments