1- using AspNetCoreServiceBusApi2 . Model ;
2- using Microsoft . EntityFrameworkCore ;
1+
32using Microsoft . OpenApi . Models ;
43using ServiceBusMessaging ;
4+ using Serilog ;
5+ using AspNetCoreServiceBusApi2 . Model ;
6+ using Microsoft . EntityFrameworkCore ;
57
68namespace AspNetCoreServiceBusApi2 ;
79
8- public class Startup
10+ internal static class StartupExtensions
911{
10- public Startup ( IConfiguration configuration )
12+ public static WebApplication ConfigureServices ( this WebApplicationBuilder builder )
1113 {
12- Configuration = configuration ;
13- }
14-
15- public IConfiguration Configuration { get ; }
14+ var services = builder . Services ;
15+ var configuration = builder . Configuration ;
1616
17- public void ConfigureServices ( IServiceCollection services )
18- {
1917 services . AddControllers ( ) ;
2018
21- var connection = Configuration . GetConnectionString ( "DefaultConnection" ) ;
19+ var connection = configuration . GetConnectionString ( "DefaultConnection" ) ;
2220
2321 services . AddDbContext < PayloadContext > ( options =>
2422 options . UseSqlite ( connection ) ) ;
@@ -37,11 +35,15 @@ public void ConfigureServices(IServiceCollection services)
3735 Title = "Payload API" ,
3836 } ) ;
3937 } ) ;
38+
39+ return builder . Build ( ) ;
4040 }
4141
42- public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
42+ public static WebApplication Configure ( this WebApplication app )
4343 {
44- if ( env . IsDevelopment ( ) )
44+ app . UseSerilogRequestLogging ( ) ;
45+
46+ if ( app . Environment . IsDevelopment ( ) )
4547 {
4648 app . UseDeveloperExceptionPage ( ) ;
4749 }
@@ -58,15 +60,14 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
5860 app . UseAuthorization ( ) ;
5961 app . UseCors ( ) ;
6062
61- app . UseEndpoints ( endpoints =>
62- {
63- endpoints . MapControllers ( ) ;
64- } ) ;
63+ app . MapControllers ( ) ;
6564
6665 app . UseSwagger ( ) ;
6766 app . UseSwaggerUI ( c =>
6867 {
6968 c . SwaggerEndpoint ( "/swagger/v1/swagger.json" , "Payload Management API V1" ) ;
7069 } ) ;
70+
71+ return app ;
7172 }
72- }
73+ }
0 commit comments