// This method gets called by the runtime. Use this method to add services to the container.
        public virtual void ConfigureServices(IServiceCollection services)
        {
            DatabaseConfiguration.ConfigureDatabase(Configuration, services);

            services.AddCors(options =>
                             options.AddPolicy("Website",
                                               builder => builder
                                               .WithOrigins(Configuration.GetSection("WEBSITE_URL").Value)
                                               .AllowAnyMethod()
                                               .AllowAnyHeader()
                                               ));

            services.AddHttpClient("CurrencyConversion", client =>
            {
                client.BaseAddress = new Uri("http://rate-exchange-1.appspot.com");
                client.DefaultRequestHeaders.Add("Accept", "application/json");
                client.DefaultRequestHeaders.Add("User-Agent", "CurrencyConversionAgent");
            });

            services.AddHttpClient("MYCA", httpClient =>
            {
                httpClient.BaseAddress = new Uri(Program.configuration.GetValue <string>("MYCA_ENTRYPOINT"));
                httpClient.DefaultRequestHeaders.Add("Accept", new List <string>(new[] { "application/json", "text/html" }));
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDistributedMemoryCache();

            services.AddSession(options =>
            {
                options.IdleTimeout        = TimeSpan.FromMinutes(30);
                options.Cookie.HttpOnly    = true;
                options.Cookie.IsEssential = true;
            });
            services.AddControllersWithViews();
            DatabaseConfiguration.ConfigureDatabase(services, Configuration);
            services.AddScoped <IDatabaseAccessService, DatabaseAccessService>();
        }