public static IServiceProvider UseStartup(IApplicationStartup applicationStartup, ILogger logger) { logger.LogInformation($@"Using startup: {applicationStartup.GetType().FullName}"); // Configuration. var configurationBuilder = new ConfigurationBuilder(); applicationStartup.ConfigureConfiguration(configurationBuilder); var configuration = configurationBuilder.Build(logger); // Services. var services = new ServiceCollection(); services.AddConfiguration(configuration, logger); applicationStartup.ConfigureServices(services); // Service provider. var serviceProvider = services.BuildServiceProvider(logger); applicationStartup.Configure(serviceProvider); // Tests. if (applicationStartup.RunTests) { applicationStartup.TestServices(serviceProvider); } return(serviceProvider); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseCors("CustomCorsPolicy"); if (env.IsDevelopment()) // Usar para exibir stacktrace das exceções { app.UseDeveloperExceptionPage(); } else // Usar para exibir mensagem custom das exceções { app.UseExceptionHandlingMiddlewares(env); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); _startup.Configure(app, env); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { _startup.Configure(app, env); }