/// <summary> /// Configure. /// </summary> /// <param name="app">IApplicationBuilder.</param> /// <param name="env">IWebHostEnvironment.</param> public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { (app.ApplicationServices.GetService <IConfiguration>() as Configuration).Init(env.ContentRootPath); app.UseExceptionHandler(new ExceptionHandlerOptions() { ExceptionHandler = (ctx) => { var feature = ctx.Features.Get <IExceptionHandlerFeature>(); app.ApplicationServices.GetService <ILogger>().Log(feature.Error); return(Task.FromResult(0)); }, }); app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto, }); app.UseStaticFiles(); app.UseRouting(); app.UseSentryTracing(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapHealthChecks("/health", new HealthCheckOptions() { ResultStatusCodes = { [HealthStatus.Healthy] = StatusCodes.Status200OK, [HealthStatus.Degraded] = StatusCodes.Status500InternalServerError, [HealthStatus.Unhealthy] = StatusCodes.Status503ServiceUnavailable, }, AllowCachingResponses = false, ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse, }); }); app.ApplicationServices.GetService <ILogger>().Info("Application started."); UpdateFeedsJobRunner.Schedule(app.ApplicationServices); }
/// <summary> /// Configure. /// </summary> /// <param name="app">IApplicationBuilder.</param> /// <param name="env">IWebHostEnvironment.</param> public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { BLL.Configuration.Init( Environment.GetEnvironmentVariable("BASEPATH") ?? env.ContentRootPath, Environment.GetEnvironmentVariable("BASEURL") ?? "http://localhost:5000", Environment.GetEnvironmentVariable("BASEFEEDCOOKIE") ?? throw new Exception("Environment variable 'BASEFEEDCOOKIE' is not set.")); app.UseExceptionHandler(new ExceptionHandlerOptions() { ExceptionHandler = (ctx) => { var feature = ctx.Features.Get <IExceptionHandlerFeature>(); logger.Log(feature.Error); return(Task.FromResult(0)); }, }); app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto, }); app.UseStaticFiles(); app.UseMvc(); logger.Info("Application started."); UpdateFeedsJobRunner.RunAsync().Wait(); }
/// <summary> /// Main. /// </summary> /// <param name="args">args.</param> public static void Main(string[] args) { UpdateFeedsJobRunner.Schedule(); BuildWebHost(args).Run(); }