Example #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddCors(Option =>
            {
                Option.AddDefaultPolicy(Builder =>
                {
                    var frontendUrl = Configuration.GetValue <string>("frontend_url");
                    Builder.WithOrigins(frontendUrl).AllowAnyMethod().AllowAnyHeader();
                });
            });
            services.AddAutoMapper(typeof(Startup));
            services.AddControllers();
            services.AddResponseCaching();
            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "MoviesAPI", Version = "v1"
                });
            });
            //services.AddSingleton<IRepository,InmemoryRepository>();
            services.AddTransient <MyactionFilter>();
        }