public void Configure( IApplicationBuilder appBuilder, IHostApplicationLifetime appLifetime, IOptions <OpserverSettings> settings, SecurityManager securityManager, IEnumerable <StatusModule> modules ) { //appBuilder.UseStaticFiles() // .UseExceptional() // //.UseMiniProfiler() // .UseAuthentication() // .Use(async (httpContext, next) => // { // Current.SetContext(new Current.CurrentContext(securityManager.CurrentProvider, httpContext)); // await next(); // }) // .UseAuthorization() // .UseRouting() // .UseEndpoints(endpoints => endpoints.MapDefaultControllerRoute()); appBuilder.UseStaticFiles() .UseExceptional() .UseRouting() .UseMiniProfiler() .UseAuthentication() .UseAuthorization() .Use(async(httpContext, next) => { Current.SetContext(new Current.CurrentContext(securityManager.CurrentProvider, httpContext)); await next(); }) .UseResponseCaching() .UseEndpoints(endpoints => { endpoints.MapDefaultControllerRoute(); }); appLifetime.ApplicationStopping.Register(OnShutdown); NavTab.ConfigureAll(modules); // TODO: UseNavTabs() or something Cache.Configure(settings); }
public void Configure( IApplicationBuilder appBuilder, IOptions <OpserverSettings> settings, SecurityManager securityManager, IEnumerable <StatusModule> modules ) { appBuilder .UseForwardedHeaders() .UseResponseCompression() .UseStaticFiles(new StaticFileOptions { OnPrepareResponse = ctx => { if (ctx.Context.Request.Query.ContainsKey("v")) // If cache-breaker versioned, cache for a year { ctx.Context.Response.Headers[HeaderNames.CacheControl] = StaticContentCacheControl; } } }) .UseExceptional() .UseRouting() .UseMiniProfiler() .UseAuthentication() .UseAuthorization() .Use((httpContext, next) => { httpContext.Response.Headers[HeaderNames.CacheControl] = DefaultCacheControl; Current.SetContext(new Current.CurrentContext(securityManager.CurrentProvider, httpContext, modules)); return(next()); }) .UseResponseCaching() .UseEndpoints(endpoints => endpoints.MapDefaultControllerRoute()); NavTab.ConfigureAll(modules); // TODO: UseNavTabs() or something Cache.Configure(settings); }