Example #1
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            HealthCheckStartup.Configure(app, env, HostConfig);
            app.UseHttpsRedirection();

            app.UseSwagger(HostConfig.Swagger);

            app.UseRouting();
            app.UseCors("AllowSpecificOrigin");

            app.UseAuthentication();

            app.UseMiddleware <CorrelationIdMiddleware>();
            app.UseMiddleware <ExceptionHandlingMiddleware>();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Example #2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvcService();
            ApplicationConfiguration(services);
            CorsConfiguration(services);

            services.AddSwagger(HostConfig.Swagger);
            services.AddAzureAd(HostConfig.AzureAd);
            services.AddAutoMapper(GetAssembliesToScanForMapperProfiles());
            services.AddCorrelation();
            services.AddTransient <IFileSystem, FileSystem>();

            // NOTE: Pick one of the below versioning services
            services.AddTransient <IVersionService, AssemblyVersionService>(); // For Version parsing via Assembly ref

            // services.AddTransient<IVersionService, JsonVersionService>();   // For Version parsing via JSON

            services.AddMvcApi();

            services.AddMovieService();

            services.AddMovieRepository(_configuration);
            services.AddFakeApiRepository();

            services.AddTransient <IHttpClientDecorator, HttpClientDecorator>();
            services.AddHttpClient("movies", (provider, client) => provider.GetRequiredService <IHttpClientDecorator>().Configure(client));
            HealthCheckStartup.ConfigureServices(services, _configuration);

            services.AddValidators();
        }