// 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.UseStaticFiles(); app.UseAuthentication(); var swaggerOptions = new SwaggerOptions(); Configuration.GetSection(nameof(SwaggerOptions)).Bind(swaggerOptions); app.UseSwagger(option => { option.RouteTemplate = swaggerOptions.JsonRoute; }); app.UseSwaggerUI(option => { option.SwaggerEndpoint(swaggerOptions.UiEndpoint, swaggerOptions.Description); }); app.UseMvc(); }
// 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(); } var swaggerOptions = new SwaggerOptions(); Configuration.GetSection(nameof(SwaggerOptions)).Bind(swaggerOptions); app.UseSwagger(option => { option.RouteTemplate = swaggerOptions.JsonRoute; }); app.UseSwaggerUI(option => { option.SwaggerEndpoint(swaggerOptions.UIEndpoint, swaggerOptions.Description); }); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IMapper mapper) { mapper.ConfigurationProvider.AssertConfigurationIsValid(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseHealthChecks("/health", new HealthCheckOptions { ResponseWriter = async(context, report) => { context.Response.ContentType = "application/json"; var response = new HealthCheckResponse { Status = report.Status.ToString(), Checks = report.Entries.Select(x => new HealthCheck { Component = x.Key, Status = x.Value.Status.ToString(), Description = x.Value.Description }), Duration = report.TotalDuration }; await context.Response.WriteAsync(JsonConvert.SerializeObject(response)); } }); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseAuthentication(); var swaggerOptions = new SwaggerOptions(); Configuration.GetSection(nameof(SwaggerOptions)).Bind(swaggerOptions); app.UseSwagger(option => { option.RouteTemplate = swaggerOptions.JsonRoute; }); app.UseSwaggerUI(option => { option.SwaggerEndpoint(swaggerOptions.UiEndpoint, swaggerOptions.Description); }); app.UseMvc(); }
// 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 { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHealthChecks("/health", new HealthCheckOptions { ResponseWriter = async(context, report) => { context.Response.ContentType = "application/json"; var response = new HealthCheckResponse { Status = report.Status.ToString(), Checks = report.Entries.Select(x => new HealthCheck { Component = x.Key, Status = x.Value.Status.ToString(), Description = x.Value.Description }), Duration = report.TotalDuration }; await context.Response.WriteAsync(JsonConvert.SerializeObject(response)); } }); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseAuthentication(); var swaggerOptions = new SwaggerOptions(); Configuration.GetSection(nameof(SwaggerOptions)).Bind(swaggerOptions); app.UseSwagger(option => { option.RouteTemplate = swaggerOptions.JsonRoute; }); app.UseSwaggerUI(option => { option.SwaggerEndpoint(swaggerOptions.UiEndpoint, swaggerOptions.Description); }); app.UseMvc(); }
// 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(); } var swaggerOptions = new SwaggerOptions(); Configuration.GetSection(nameof(swaggerOptions)).Bind(swaggerOptions); app.UseSwagger(option => { option.RouteTemplate = swaggerOptions.JsonRoute; }); app.UseSwaggerUI(option => { option.SwaggerEndpoint(swaggerOptions.UIEndpoint, swaggerOptions.Description); }); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseAuthentication(); // Swagger Run var optionSwagger = new RewriteOptions(); optionSwagger.AddRedirect("^$", "swagger"); app.UseRewriter(optionSwagger); app.UseMvc(); }