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);
        }
예제 #2
0
        // 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);
        }
예제 #3
0
 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
     _startup.Configure(app, env);
 }