コード例 #1
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
     CORSConfig.Configure(app);
     Authentication.Configure(app);
     app.UseMvc();
     SwaggerConfig.Configure(app);
 }
コード例 #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            CORSConfig.ConfigureServices(services);
            services.AddMvcCore()
            .AddAuthorization()
            .AddJsonFormatters();

            services.AddAuthentication("Bearer")
            .AddIdentityServerAuthentication(options =>
            {
                options.Authority            = endponit + tenantId;
                options.RequireHttpsMetadata = false;
            });
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            Paging.ConfigureServices(services);
            SwaggerConfig.ConfigureServices(services);
            AppIDConfigUrl.ConfigureServices(services);

            services.AddDbContext <ChoThueXeContext>(options =>
                                                     options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            RepositoryConfig.ConfigureServices(services);
        }
コード例 #3
0
ファイル: Startup.cs プロジェクト: AlexEp/IMDBScraper
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // *** init MongoDB *** */
            var mongoSection  = Configuration.GetSection("MongoDB");
            var mongoDBConfig = new MongoDBConfig();

            mongoSection.Bind(mongoDBConfig);

            services.AddTransient <IActorRepository>(provider => new ActorRepository(mongoDBConfig));

            /* *** [init Swagger] *** */
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "IMDB Scraper API", Version = "v1"
                });
            });

            /* *** [ELSE] *** */
            services.AddControllers();

            var corsSection = Configuration.GetSection("CORS");
            var corsConfig  = new CORSConfig();

            corsSection.Bind(corsConfig);

            services.AddCors(options =>
            {
                options.AddPolicy(name: CORS_POLICY,
                                  builder =>
                {
                    builder.WithOrigins(corsConfig.FrontEndURL)
                    .AllowAnyMethod()
                    .AllowAnyHeader()
                    .AllowCredentials();
                });
            });
        }