// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, CarRentalContext carRentalContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(appBuilder => { appBuilder.Run(async context => { context.Response.StatusCode = 500; await context.Response.WriteAsync("An unexpected fault happened. Try again later."); }); }); } app.UseSwagger(); app.UseSwaggerUI(setupAction => { setupAction.SwaggerEndpoint("/swagger/v1/swagger.json", "CarRental API V1"); }); app.UseRouting(); app.UseCors(MyAllowOrigins); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); carRentalContext.InitialDbData(); }