Esempio n. 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IMockDataSeeder mockSeeder)
        {
            //Seeding mock data
            mockSeeder.MockSeedInit().Wait();

            loggerFactory.AddConsole();

            //As this is a demo, we will continue to use Developer Exceptions.
            app.UseDeveloperExceptionPage();

            //In production you would change that.
            //if (env.IsDevelopment())
            //{
            //    app.UseDeveloperExceptionPage();
            //}
            //else
            //{
            //    app.UseExceptionHandler();
            //}

            app.UseMvc();

            //Configuring Swagger API documentation and its UI
            app.UseSwagger(c =>
            {
                c.PreSerializeFilters.Add((swaggerDoc, httpReq) => swaggerDoc.Host = httpReq.Host.Value);
            });

            //Single Swagger page for all controllers
            //app.UseSwaggerUI(c =>
            //{
            //    c.SwaggerEndpoint("/swagger/v1/swagger.json", "Contoso Cognitive Pipeline V1");
            //});

            //Separate swagger page/json for each controller
            app.UseSwaggerUI(c =>
            {
                foreach (var api in apis)
                {
                    c.SwaggerEndpoint($"/swagger/{api}/swagger.json", api);
                }

                c.RoutePrefix = string.Empty; // Makes Swagger UI the root page
            });
        }
Esempio 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, ILoggerFactory loggerFactory, IMockDataSeeder mockSeeder)
        {
            //Seeding mock data
            mockSeeder.MockSeedInit().Wait();

            loggerFactory.AddConsole();

            //As this is a demo, we will continue to use Developer Exceptions.
            app.UseDeveloperExceptionPage();

            //In production you would change that.
            //if (env.IsDevelopment())
            //{
            //    app.UseDeveloperExceptionPage();
            //}
            //else
            //{
            //    app.UseExceptionHandler();
            //}

            app.UseMvc();

            //Configuring Swagger API documentation and its UI
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Contoso Cognitive Pipeline V1");
            });
        }