1- using System ;
2- using System . Collections . Generic ;
3- using System . Data . Common ;
4- using System . IdentityModel . Tokens . Jwt ;
5- using System . Linq ;
6- using System . Reflection ;
7- using System . Threading ;
8- using System . Threading . Tasks ;
9- using Autofac ;
1+ using Autofac ;
102using Autofac . Extensions . DependencyInjection ;
113using Devspaces . Support ;
124using HealthChecks . UI . Client ;
13- using Microsoft . ApplicationInsights . Extensibility ;
14- using Microsoft . ApplicationInsights . ServiceFabric ;
155using Microsoft . AspNetCore . Authentication . JwtBearer ;
166using Microsoft . AspNetCore . Builder ;
177using Microsoft . AspNetCore . Diagnostics . HealthChecks ;
18- using Microsoft . AspNetCore . Hosting ;
198using Microsoft . AspNetCore . Http ;
209using Microsoft . AspNetCore . Mvc ;
2110using Microsoft . Azure . ServiceBus ;
3120using Microsoft . Extensions . Diagnostics . HealthChecks ;
3221using Microsoft . Extensions . Logging ;
3322using RabbitMQ . Client ;
34- using Swashbuckle . AspNetCore . Swagger ;
23+ using System ;
24+ using System . Collections . Generic ;
25+ using System . Data . Common ;
26+ using System . IdentityModel . Tokens . Jwt ;
27+ using System . Reflection ;
28+ using System . Threading ;
3529using Webhooks . API . Infrastructure ;
3630using Webhooks . API . IntegrationEvents ;
3731using Webhooks . API . Services ;
@@ -84,22 +78,25 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
8478 app . UsePathBase ( pathBase ) ;
8579 }
8680
87- app . UseHealthChecks ( "/hc" , new HealthCheckOptions ( )
88- {
89- Predicate = _ => true ,
90- ResponseWriter = UIResponseWriter . WriteHealthCheckUIResponse
91- } ) ;
92-
93- app . UseHealthChecks ( "/liveness" , new HealthCheckOptions
94- {
95- Predicate = r => r . Name . Contains ( "self" )
96- } ) ;
97-
9881 app . UseCors ( "CorsPolicy" ) ;
9982
10083 ConfigureAuth ( app ) ;
10184
102- app . UseMvcWithDefaultRoute ( ) ;
85+ app . UseRouting ( ) ;
86+ app . UseEndpoints ( endpoints =>
87+ {
88+ endpoints . MapHealthChecks ( "/hc" , new HealthCheckOptions ( )
89+ {
90+ Predicate = _ => true ,
91+ ResponseWriter = UIResponseWriter . WriteHealthCheckUIResponse
92+ } ) ;
93+ endpoints . MapHealthChecks ( "/liveness" , new HealthCheckOptions
94+ {
95+ Predicate = r => r . Name . Contains ( "self" )
96+ } ) ;
97+
98+ endpoints . MapDefaultControllerRoute ( ) ;
99+ } ) ;
103100
104101 app . UseSwagger ( )
105102 . UseSwaggerUI ( c =>
@@ -138,19 +135,7 @@ static class CustomExtensionMethods
138135 public static IServiceCollection AddAppInsight ( this IServiceCollection services , IConfiguration configuration )
139136 {
140137 services . AddApplicationInsightsTelemetry ( configuration ) ;
141- var orchestratorType = configuration . GetValue < string > ( "OrchestratorType" ) ;
142-
143- if ( orchestratorType ? . ToUpper ( ) == "K8S" )
144- {
145- // Enable K8s telemetry initializer
146- services . AddApplicationInsightsKubernetesEnricher ( ) ;
147- }
148- if ( orchestratorType ? . ToUpper ( ) == "SF" )
149- {
150- // Enable SF telemetry initializer
151- services . AddSingleton < ITelemetryInitializer > ( ( serviceProvider ) =>
152- new FabricTelemetryInitializer ( ) ) ;
153- }
138+ services . AddApplicationInsightsKubernetesEnricher ( ) ;
154139
155140 return services ;
156141 }
@@ -161,7 +146,7 @@ public static IServiceCollection AddCustomMVC(this IServiceCollection services,
161146 {
162147 options . Filters . Add ( typeof ( HttpGlobalExceptionFilter ) ) ;
163148 } )
164- . SetCompatibilityVersion ( CompatibilityVersion . Version_2_2 )
149+ . SetCompatibilityVersion ( CompatibilityVersion . Version_3_0 )
165150 . AddControllersAsServices ( ) ;
166151
167152 services . AddCors ( options =>
@@ -203,23 +188,26 @@ public static IServiceCollection AddSwagger(this IServiceCollection services, IC
203188 services . AddSwaggerGen ( options =>
204189 {
205190 options . DescribeAllEnumsAsStrings ( ) ;
206- options . SwaggerDoc ( "v1" , new Swashbuckle . AspNetCore . Swagger . Info
191+ options . SwaggerDoc ( "v1" , new Microsoft . OpenApi . Models . OpenApiInfo
207192 {
208193 Title = "eShopOnContainers - Webhooks HTTP API" ,
209194 Version = "v1" ,
210- Description = "The Webhooks Microservice HTTP API. This is a simple webhooks CRUD registration entrypoint" ,
211- TermsOfService = "Terms Of Service"
195+ Description = "The Webhooks Microservice HTTP API. This is a simple webhooks CRUD registration entrypoint"
212196 } ) ;
213197
214- options . AddSecurityDefinition ( "oauth2" , new OAuth2Scheme
198+ options . AddSecurityDefinition ( "oauth2" , new Microsoft . OpenApi . Models . OpenApiSecurityScheme
215199 {
216- Type = "oauth2" ,
217- Flow = "implicit" ,
218- AuthorizationUrl = $ "{ configuration . GetValue < string > ( "IdentityUrlExternal" ) } /connect/authorize",
219- TokenUrl = $ "{ configuration . GetValue < string > ( "IdentityUrlExternal" ) } /connect/token",
220- Scopes = new Dictionary < string , string > ( )
200+ Flows = new Microsoft . OpenApi . Models . OpenApiOAuthFlows ( )
221201 {
222- { "webhooks" , "Webhooks API" }
202+ Implicit = new Microsoft . OpenApi . Models . OpenApiOAuthFlow ( )
203+ {
204+ AuthorizationUrl = new Uri ( $ "{ configuration . GetValue < string > ( "IdentityUrlExternal" ) } /connect/authorize") ,
205+ TokenUrl = new Uri ( $ "{ configuration . GetValue < string > ( "IdentityUrlExternal" ) } /connect/token") ,
206+ Scopes = new Dictionary < string , string > ( )
207+ {
208+ { "marketing" , "Marketing API" }
209+ }
210+ }
223211 }
224212 } ) ;
225213
0 commit comments