예제 #1
0
 public void ConfigureContainer(ContainerBuilder containerBuilder)
 {
     if (Environment.IsEnvironment("UnitTest"))
     {
         ApplicationBootstrap.RegisterServicesForTesting(containerBuilder);
     }
     else
     {
         ApplicationBootstrap.RegisterServices(containerBuilder);
     }
 }
예제 #2
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddApplicationInsightsTelemetry();

            services.AddMvc(options =>
            {
                options.Filters.Add <UnhandledExceptionFilter>();
                options.Filters.Add <ModelValidationFilter>();
            })
            .AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining <AddPassengerCommandValidator>());;

            services.AddCors();

            if (Environment.IsEnvironment("UnitTest"))
            {
                return(ApplicationBootstrap.RegisterServicesForTesting(services));
            }

            return(ApplicationBootstrap.RegisterServices(services, Configuration));
        }
예제 #3
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            AutofacContainer = app.ApplicationServices.GetAutofacRoot();
            ApplicationBootstrap.SetAutofacContainer(AutofacContainer);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors(policy =>
            {
                policy.AllowAnyOrigin()
                .AllowAnyHeader()
                .AllowAnyMethod();
            });

            var healthCheckResponseWriterProvider = new HealthCheckerResponseProvider(env);

            app.UseHealthChecks("/health/ready", new HealthCheckOptions
            {
                Predicate      = check => check.Tags.Contains("ready"),
                ResponseWriter = healthCheckResponseWriterProvider.Writer
            });

            app.UseHealthChecks("/health/live", new HealthCheckOptions
            {
                Predicate      = _ => false,
                ResponseWriter = healthCheckResponseWriterProvider.Writer
            });
            app.UseSwagger();
            app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); });

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