// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); TryMigrateDatabase(app, loggerFactory); app.UseAuthentication(env); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } bool startHangfire = true; #if DEBUG // do not start Hangfire if we are running tests. foreach (var assem in Assembly.GetEntryAssembly().GetReferencedAssemblies()) { if (assem.FullName.ToLowerInvariant().StartsWith("xunit")) { startHangfire = false; break; } } #endif if (startHangfire) { // enable Hangfire app.UseHangfireServer(); // disable the back to site link DashboardOptions dashboardOptions = new DashboardOptions(); dashboardOptions.AppPath = null; app.UseHangfireDashboard("/hangfire", dashboardOptions); // this enables the /hangfire action } app.UseResponseCompression(); app.UseMvc(); app.UseDefaultFiles(); app.UseStaticFiles(); app.UseSwagger(); app.UseSwaggerUi(); if (startHangfire) { HangfireTools.ClearHangfire(); // this should be set as an environment variable. // Only enable when doing a new PROD deploy to populate CCW data and link it to the bus data. if (!string.IsNullOrEmpty(Configuration["ENABLE_ANNUAL_ROLLOVER"])) { CreateHangfireAnnualRolloverJob(loggerFactory); } } }
/// <summary> /// Configure the HTTP request pipeline /// </summary> /// <param name="app"></param> /// <param name="env"></param> /// <param name="loggerFactory"></param> public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); // web site error handler app.UseWhen(x => !x.Request.Path.Value.StartsWith("/api"), builder => { builder.UseExceptionHandler(Configuration.GetSection("Constants:ErrorUrl").Value); }); // IMPORTANT: This session call MUST go before UseMvc() app.UseSession(); // authenticate users app.UseAuthentication(); // update database environment TryMigrateDatabase(app, loggerFactory); // do not start Hangfire if we are running tests. bool startHangfire = true; #if DEBUG foreach (var assem in Assembly.GetEntryAssembly().GetReferencedAssemblies()) { if (assem.FullName.ToLowerInvariant().StartsWith("xunit")) { startHangfire = false; break; } } #endif if (startHangfire) { // enable Hangfire app.UseHangfireServer(); // disable the back to site link DashboardOptions dashboardOptions = new DashboardOptions() { AppPath = null }; // enable the /hangfire action app.UseHangfireDashboard(Configuration.GetSection("Constants:HangfireUrl").Value, dashboardOptions); } app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}"); }); if (_hostingEnv.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUi(); } if (startHangfire) { HangfireTools.ClearHangfire(); // this should be set as an environment variable. // only enable when doing a new PROD deploy to populate CCW data and link it to the bus data. if (!string.IsNullOrEmpty(Configuration["ENABLE_ANNUAL_ROLLOVER"])) { CreateHangfireAnnualRolloverJob(loggerFactory); } } }