コード例 #1
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, TodoDbContext dbContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Todo V1");
                c.RoutePrefix = string.Empty;
            });

            app.UseExceptionHandling();
            app.UseCorrelationId();
            app.UseRequestLogging();
            app.UseContentLocation();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseGraphQL().UsePlayground();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            // Seed database only if seeding is enabled in appsettings (default = true)
            if (Configuration.GetValue <bool>(Constants.SeedKey))
            {
                dbContext.Seed();
            }
        }