Ejemplo n.º 1
0
 public PoliticalDivisionsController(ProvinceRules provinceRules, ILoggerFactory loggerFactory)
 {
     _rules  = provinceRules;
     _logger = loggerFactory.CreateLogger <PoliticalDivisionsController>();
 }
Ejemplo n.º 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, DataSeeder seeder, ProvinceRules provinceRules)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Use(async(context, next) =>
            {
                await next();

                if (context.Response.StatusCode == 404 &&
                    !Path.HasExtension(context.Request.Path.Value) &&
                    !context.Request.Path.Value.StartsWith("/api/", StringComparison.CurrentCulture))
                {
                    context.Request.Path = "/";
                    await next();
                }
            });

            app.UseDefaultFiles();
            app.UseStaticFiles();

            app.UseAuthentication();

            // Enable middleware to serve generated Swagger as a JSON endpoint.
            app.UseSwagger();

            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Common 360 api");
            });

            app.UseMvc();

            app.ConfigureMaps();

            seeder.Seed(provinceRules.GetPredefinedProvincesAsync().Result);
        }