Bit.Api.Startup.Configure C# (CSharp) Méthode

Configure() public méthode

public Configure ( IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, GlobalSettings globalSettings ) : void
app IApplicationBuilder
env IHostingEnvironment
loggerFactory ILoggerFactory
globalSettings Bit.Core.GlobalSettings
Résultat void
        public void Configure(
            IApplicationBuilder app,
            IHostingEnvironment env,
            ILoggerFactory loggerFactory,
            GlobalSettings globalSettings)
        {
            loggerFactory.AddConsole();
            loggerFactory.AddDebug();

            if(!env.IsDevelopment())
            {
                loggerFactory.AddLoggr(
                    (category, logLevel, eventId) =>
                    {
                        // Bad security stamp exception
                        if(category == typeof(JwtBearerMiddleware).FullName && eventId.Id == 3 && logLevel == LogLevel.Error)
                        {
                            return false;
                        }

                        // IP blocks
                        if(category == typeof(IpRateLimitMiddleware).FullName && logLevel >= LogLevel.Information)
                        {
                            return true;
                        }

                        return logLevel >= LogLevel.Error;
                    },
                    globalSettings.Loggr.LogKey,
                    globalSettings.Loggr.ApiKey);
            }

            // Rate limiting
            app.UseMiddleware<CustomIpRateLimitMiddleware>();

            // Insights
            app.UseApplicationInsightsRequestTelemetry();
            app.UseApplicationInsightsExceptionTelemetry();

            // Add static files to the request pipeline.
            app.UseStaticFiles();

            // Add Cors
            app.UseCors("All");

            // Add Jwt authentication to the request pipeline.
            app.UseJwtBearerIdentity();

            // Add MVC to the request pipeline.
            app.UseMvc();
        }