コード例 #1
0
        public void Configure(IApplicationBuilder app,
                              // IRecurringJobManager recurringJobManager,
                              IServiceProvider serviceProvider /*, ILoggerFactory loggerFactory*/)
        {
            if (Environment.IsDevelopment())
            {
                UserSeed.SeedDatabase(app);
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }

            app.UseCors(x =>
            {
                x.WithOrigins(Configuration["App:CorsOrigins"]
                              .Split(",", StringSplitOptions.RemoveEmptyEntries)
                              .Select(o => o.RemovePostFix("/"))
                              .ToArray())
                .AllowAnyMethod()
                .AllowAnyHeader();
            });



            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

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

            //if (Environment.IsDevelopment())
            //{ }
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            app.UseSwagger();

            app.UseSwaggerUI(options =>
            {
                options.SwaggerEndpoint("http://localhost:5001/" + "swagger/v1/swagger.json",
                                        "sharedbook API");
            });
            //app.useswaggerui(options =>
            //{
            //    options.swaggerendpoint(configuration["app:serverrootaddress"].ensureendswith('/') + "swagger/v1/swagger.json", "lme.web api v1");
            //});


            //app.UseHangfireDashboard();
            //app.UseHangfireServer();
            //recurringJobManager.AddOrUpdate(
            //    "Run every minute",
            //    //() => serviceProvider.GetService<IRecurringJob>().BackgroundJob(),
            //    () => serviceProvider.GetService<IBookingService>().VerifyPaystack(),
            //    "*/5 * * * *");
            //app.UseFileServer();
        }