public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Latest); services.AddGlobalExceptionHandlerMiddleware(); // Ajustes relacionados à GDPR services.Configure <CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); // habilita a gravacao de sessao. services.AddSession(opts => { opts.Cookie.IsEssential = true; // make the session cookie Essential }); services.AddResponseCompression(); // Comprimir todas as requisicoes. services.AddHttpContextAccessor(); services.AddCors(options => { options.AddPolicy("CorsPolicy", builder => builder .SetIsOriginAllowed((host) => true) .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); }); services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new OpenApiInfo { Title = "Livraria HTTP API", Version = "v1", Description = "Serviço Livraria HTTP API" }); }); NativeDependencyInjection dp = new NativeDependencyInjection(); dp.Configure(services, Configuration); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // configure strongly typed settings objects var appSettingsSection = Configuration.GetSection("AppSettings"); services.Configure <AppSettings>(appSettingsSection); var appSettings = appSettingsSection.Get <AppSettings>(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); // In production, the React files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/build"; }); var dp = new NativeDependencyInjection(); dp.Configure(services); AutoMapperConfig.RegisterMappings(); }