// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { // Enable caching and register any caching services. CacheAspect.Enabled = true; BlobCacheAttribute.AddService("default", app.ApplicationServices.GetService <IBlobCacheService>()); // Enable cancellation aspects and register request timeout configuration. CancellationTokenTimeoutAspect.Enabled = true; CancellationTokenTimeoutAttribute.SetTimeoutConfiguration(Configuration.GetSection("RequestTimeouts")); UpdateDatabase(app); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHttpsRedirection(); app.UseHsts(hsts => hsts.MaxAge(365).IncludeSubdomains()); } if (Configuration.GetValue <bool>("enableSwagger")) { app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Data API V1"); c.RoutePrefix = "docs"; }); var option = new RewriteOptions(); option.AddRedirect("^$", "docs"); app.UseRewriter(option); } // ReSharper disable once CommentTypo // Adds Brotli and Gzip compressing app.UseResponseCompression(); app.UseCors(options => options .WithOrigins( "http://localhost:3000", "http://localhost:3001", "https://localhost:3000", "https://localhost:3001") .AllowAnyMethod() .AllowAnyHeader()); app.UseMvc(); app.UseHealthChecks("/api/health"); }
public void TimeoutExceededWithNoConfigurationSection() { CancellationTokenTimeoutAttribute.SetTimeoutConfiguration(null); try { var exception = Assert.Throws <ArgumentException>(() => TestMethods.AddTimeoutWithMissingConfiguration()); Assert.StartsWith("Timeout configuration section cannot be null", exception.Message); } finally { CancellationTokenTimeoutAttribute.SetTimeoutConfiguration(TimeoutConfiguration); } }