Ejemplo n.º 1
0
        public void Configure(IApplicationBuilder app, IHostEnvironment env, BusConfigurator busConfigurator)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMiddleware(typeof(ErrorHandlingMiddleware));

            app.UseRequestLocalization(new RequestLocalizationOptions
            {
                DefaultRequestCulture = new RequestCulture(Localization.DefaultCultureInfo.TwoLetterISOLanguageName),
                SupportedCultures     = Localization.SupportedCultures, // Formatting numbers, dates, etc.
                SupportedUICultures   = Localization.SupportedCultures  // UI strings that are localized.
            });

            app.UseSwagger();
            app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", $"{Metadata.ApplicationName} API V1"); });

            app.UseCors(x =>
                        x.AllowAnyMethod()
                        .WithOrigins("http://localhost:8080", "https://baernhaeckt.z16.web.core.windows.net")
                        .AllowAnyHeader()
                        .AllowCredentials());

            app.UseRouting();

            app.UseHealthChecks("/health", new HealthCheckOptions
            {
                Predicate      = _ => true,
                ResponseWriter = HealthCheckJsonResponseWriter.WriteHealthCheckJsonResponse
            });

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers().RequireAuthorization();
                endpoints.MapHub <NewsfeedHub>("/newsfeed");
            });

            busConfigurator.ScanSubscribers();
        }