mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
tidy ConfigureServices()
This commit is contained in:
parent
dae75ab62f
commit
60dc3303ef
4 changed files with 57 additions and 17 deletions
|
|
@ -1,6 +1,9 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.ApplicationInsights.Extensibility.Implementation;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
|
|
@ -11,12 +14,33 @@ public static class ConfigureServicesCollection
|
|||
{
|
||||
public static void AddFilterListsApi(this IServiceCollection services)
|
||||
{
|
||||
services.AddRouting(options => options.LowercaseUrls = true);
|
||||
services.ConfigureCookiePolicy();
|
||||
services.AddMvcCustom();
|
||||
services.AddRoutingCustom();
|
||||
services.AddApiVersioning();
|
||||
services.AddSwaggerGenCustom();
|
||||
TelemetryDebugWriter.IsTracingDisabled = true;
|
||||
}
|
||||
|
||||
private static void ConfigureCookiePolicy(this IServiceCollection services)
|
||||
{
|
||||
services.Configure<CookiePolicyOptions>(options =>
|
||||
{
|
||||
options.CheckConsentNeeded = context => true;
|
||||
options.MinimumSameSitePolicy = SameSiteMode.None;
|
||||
});
|
||||
}
|
||||
|
||||
private static void AddMvcCustom(this IServiceCollection services)
|
||||
{
|
||||
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
|
||||
}
|
||||
|
||||
private static void AddRoutingCustom(this IServiceCollection services)
|
||||
{
|
||||
services.AddRouting(options => options.LowercaseUrls = true);
|
||||
}
|
||||
|
||||
private static void AddSwaggerGenCustom(this IServiceCollection services)
|
||||
{
|
||||
services.AddSwaggerGen(c =>
|
||||
|
|
|
|||
|
|
@ -6,9 +6,7 @@
|
|||
using JetBrains.Annotations;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
|
@ -28,12 +26,6 @@ public Startup(IConfiguration configuration)
|
|||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.Configure<CookiePolicyOptions>(options =>
|
||||
{
|
||||
options.CheckConsentNeeded = context => true;
|
||||
options.MinimumSameSitePolicy = SameSiteMode.None;
|
||||
});
|
||||
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
|
||||
services.AddFilterListsServices(Configuration);
|
||||
services.AddFilterListsApi();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace FilterLists.Web.DependencyInjection.Extensions
|
||||
{
|
||||
public static class ConfigureServicesCollection
|
||||
{
|
||||
public static void AddFilterListsWeb(this IServiceCollection services)
|
||||
{
|
||||
services.ConfigureCookiePolicy();
|
||||
services.AddMvcCustom();
|
||||
}
|
||||
|
||||
private static void ConfigureCookiePolicy(this IServiceCollection services)
|
||||
{
|
||||
services.Configure<CookiePolicyOptions>(options =>
|
||||
{
|
||||
options.CheckConsentNeeded = context => true;
|
||||
options.MinimumSameSitePolicy = SameSiteMode.None;
|
||||
});
|
||||
}
|
||||
|
||||
private static void AddMvcCustom(this IServiceCollection services)
|
||||
{
|
||||
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
using FilterLists.Web.DependencyInjection.Extensions;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SpaServices.Webpack;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
|
|
@ -13,12 +12,7 @@ public class Startup
|
|||
{
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.Configure<CookiePolicyOptions>(options =>
|
||||
{
|
||||
options.CheckConsentNeeded = context => true;
|
||||
options.MinimumSameSitePolicy = SameSiteMode.None;
|
||||
});
|
||||
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
|
||||
services.AddFilterListsWeb();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
|
|
|
|||
Loading…
Reference in a new issue