예제 #1
0
        public void Configure(
            IServiceProvider serviceProvider,
            IApplicationBuilder app,
            IHostingEnvironment env,
            IApplicationLifetime appLifetime,
            ILoggerFactory loggerFactory,
            IApiVersionDescriptionProvider apiVersionProvider,
            ApiDataDogToggle datadogToggle,
            ApiDebugDataDogToggle debugDataDogToggle,
            MsSqlStreamStore streamStore)
        {
            StartupHelpers.EnsureSqlStreamStoreSchema <Startup>(streamStore, loggerFactory);

            if (datadogToggle.FeatureEnabled)
            {
                if (debugDataDogToggle.FeatureEnabled)
                {
                    StartupHelpers.SetupSourceListener(serviceProvider.GetRequiredService <TraceSource>());
                }

                app.UseDataDogTracing(
                    serviceProvider.GetRequiredService <TraceSource>(),
                    _configuration["DataDog:ServiceName"],
                    pathToCheck => pathToCheck != "/");
            }

            app.UseDefaultForApi(new StartupOptions
            {
                ApplicationContainer = _applicationContainer,
                ServiceProvider      = serviceProvider,
                HostingEnvironment   = env,
                ApplicationLifetime  = appLifetime,
                LoggerFactory        = loggerFactory,
                Api =
                {
                    VersionProvider         = apiVersionProvider,
                    Info                    = groupName => $"Basisregisters Vlaanderen - Bank Account Number Registry API {groupName}",
                    CustomExceptionHandlers = new IExceptionHandler[]
                    {
                        new ValidationExceptionHandling(),
                    }
                },
                MiddlewareHooks =
                {
                    AfterMiddleware = x => x.UseMiddleware <AddNoCacheHeadersMiddleware>(),
                },
            });
        }