Example #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApiVersionDescriptionProvider apiVersionDescriptionProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            //app.UseHttpsRedirection();

            app.UseRouting();

            CorsOrginConfiguration.Configure(app);

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

            SwaggerConfiguration.Configure(app, SwaggerConfig, apiVersionDescriptionProvider);

            app.UseHealthChecks("/hc");

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Example #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            SwaggerConfiguration.Configure(app, Configuration);

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

            app.UseHttpsRedirection();
            app.UseSerilogRequestLogging();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "MyArea",
                    template: "{area:exists}/{controller=Home}/{action=Index}/{id?}");

                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Example #3
0
        public void Configure(IApplicationBuilder applicationBuilder, IHostingEnvironment environment)
        {
            if (environment.IsDevelopment())
            {
                applicationBuilder.UseDeveloperExceptionPage();
            }
            else
            {
                applicationBuilder.UseHsts();
            }

            Configuration = ConfigurationBuilderConfiguration.Configure(applicationBuilder, environment);

            CorsConfiguration.Configure(applicationBuilder);
            SwaggerConfiguration.Configure(applicationBuilder);

            applicationBuilder
            .UseHttpsRedirection()
            .UseMvc()
            .Run(context =>
            {
                // Make the Swagger UI be the default when a Controller Action is not found
                context.Response.Redirect("swagger");
                return(Task.CompletedTask);
            });
        }
Example #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseHttpsRedirection();

            app.UseAuthentication();
            app.UseAuthorization();
            app.UseRouting(); // must be below app.UseAuthentication();
            //app.UseMvc(); // .net core < 3.0

            SwaggerConfiguration.Configure(app);

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Example #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers().AddNewtonsoftJson();

            services.AddDbContext <AmandaStoreDBContext>();
            DependencyInjection.Dependencias(services);
            SwaggerConfiguration.Configure(services);
        }
Example #6
0
        /// <summary>
        /// Configures the specified application.
        /// </summary>
        /// <param name="app">The application.</param>
        /// <param name="env">The env.</param>
        /// <param name="loggerFactory">The logger factory.</param>
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseMvc();

            //Cunfigure the Swagger API documentation
            SwaggerConfiguration.Configure(app);
        }
Example #7
0
 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
 {
     DatabaseConfiguration.Configure(app);
     LoggingConfiguration.Configure(app, _configuration, loggerFactory);
     RewriteConfiguration.Configure(app, env);
     SimpleInjectorConfiguration.Configure(app);
     CorsConfiguration.Configure(app, _configuration);
     MvcConfiguration.Configure(app, env);
     SwaggerConfiguration.Configure(app);
     AutoMapperConfiguration.Configure();
     FluentValidationConfiguration.Configure();
     HangfireConfiguration.Configure(app, _configuration);
 }
Example #8
0
        public void ConfigureServices(IServiceCollection services)
        {
            BindConfiguration(services);
            CorsConfiguration.Configure(services);

            IMvcBuilder mvcBuilder = services
                                     .AddAutoMapper()
                                     .AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            JsonFormattingConfiguration.Configure(mvcBuilder);

            DependencyInjectionConfiguration.Configure(services);
            SwaggerConfiguration.Configure(services);
        }
Example #9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
            });

            //app.UseHttpsRedirection();

            // Config for upload file
            app.UseStaticFiles();
            app.UseStaticFiles(new StaticFileOptions()
            {
                FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"Assets")),
                RequestPath  = new PathString("/Assets")
            });

            app.UseRouting();

            // global cors policy
            app.UseCors(x => x
                        .SetIsOriginAllowed(origin => true)
                        .AllowAnyMethod()
                        .AllowAnyHeader()
                        .AllowCredentials());

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

            //Configure the Swagger API documentation
            SwaggerConfiguration.Configure(app);

            app.UseMiddleware <ExceptionHandlerMiddleware>();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Example #10
0
        /// <summary>
        /// Configures the specified application.
        /// </summary>
        /// <param name="app">The application.</param>
        /// <param name="env">The env.</param>
        /// <param name="loggerFactory">The logger factory.</param>
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection(DefaultConstants.Logging));
            loggerFactory.AddDebug();
#if RELEASE
            loggerFactory.AddFile(Configuration.GetSection("Logging"));
#endif
            // Localization support
            LocalizationConfiguration.Configure(app);

            app.UseMiddleware <ExceptionHandlerMiddleware>();

            app.UseStaticFiles();

            //Cunfigure the Swagger API documentation
            SwaggerConfiguration.Configure(app);

            app.UseMvc();
        }
Example #11
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment 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();
            }
            SwaggerConfiguration.Configure(app);
            app.UseHttpsRedirection();
            app.UseMvc();

            using (var scope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                using (var context = scope.ServiceProvider.GetRequiredService <PHContext>())
                {
                    DbInitializer.Seed(context);
                }
            }
        }
Example #12
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }
            app.UseCors(cors =>
            {
                cors.AllowAnyHeader();
                cors.AllowAnyOrigin();
                cors.AllowAnyMethod();
            });
            SwaggerConfiguration.Configure(app);

            app.UseExceptionHandler(a => new ExceptionHandlerMiddleware().Manipular(a));

            ConfigureAuth(app);

            app.UseMvc();
        }