예제 #1
0
        public static void ConfigureCommonMiddleWare(this IApplicationBuilder app, IWebHostEnvironment env,
                                                     ILoggerFactory loggerFactory,
                                                     string swaggerEndPointUrl, string swaggerEndpointName)
        {
            if (env.IsAnyDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            if (!env.IsProduction())
            {
                app.UseSwagger();
                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint(swaggerEndPointUrl, swaggerEndpointName);
                    c.RoutePrefix = string.Empty;
                    c.OAuthClientId(Constants.Idp.ClientId.SandboxSwagger);
                    c.OAuthUsePkce();
                });
            }

            app.UseSerilogRequestLogging();

            app.ConfigureExceptionHandler(loggerFactory);

            app.UseMiddleware <RateLimiterMiddleware>();

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseCorsPolicy();

            app.UseAuthentication();

            app.UseAuthorization();

            app.UseMiddleware <ThreadPrincipalMiddleware>();

            app.UseMiddleware <EnrichLogFromContextMiddleware>();
        }