using System.IO.Compression; using ChrisKaczor.HomeMonitor.Weather.Service.Data; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.ResponseCompression; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; namespace ChrisKaczor.HomeMonitor.Weather.Service { public class Startup { public void ConfigureServices(IServiceCollection services) { services.AddTransient(); services.AddHostedService(); services.Configure(options => { options.Level = CompressionLevel.Optimal; }); services.AddResponseCompression(options => { options.Providers.Add(); options.EnableForHttps = true; }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0); } public void Configure(IApplicationBuilder applicationBuilder, IWebHostEnvironment environment) { if (environment.IsDevelopment()) applicationBuilder.UseDeveloperExceptionPage(); var database = applicationBuilder.ApplicationServices.GetService(); database.EnsureDatabase(); applicationBuilder.UseResponseCompression(); applicationBuilder.UseRouting(); applicationBuilder.UseEndpoints(endpoints => { endpoints.MapDefaultControllerRoute(); }); } } }