|
22 | 22 | using Microsoft.eShopWeb.Infrastructure.Data; |
23 | 23 | using Microsoft.eShopWeb.Infrastructure.Identity; |
24 | 24 | using Microsoft.eShopWeb.Web.Configuration; |
| 25 | +using Microsoft.eShopWeb.Web.HealthChecks; |
25 | 26 | using Microsoft.Extensions.Configuration; |
26 | 27 | using Microsoft.Extensions.DependencyInjection; |
27 | 28 | using Microsoft.Extensions.Diagnostics.HealthChecks; |
@@ -136,7 +137,10 @@ public void ConfigureServices(IServiceCollection services) |
136 | 137 | options.Conventions.AuthorizePage("/Basket/Checkout"); |
137 | 138 | }); |
138 | 139 | services.AddHttpContextAccessor(); |
139 | | - services.AddHealthChecks(); |
| 140 | + services |
| 141 | + .AddHealthChecks() |
| 142 | + .AddCheck<ApiHealthCheck>("api_health_check", tags: new[] { "apiHealthCheck" }) |
| 143 | + .AddCheck<HomePageHealthCheck>("home_page_health_check", tags: new[] { "homePageHealthCheck" }); |
140 | 144 | services.Configure<ServiceConfig>(config => |
141 | 145 | { |
142 | 146 | config.Services = new List<ServiceDescriptor>(services); |
@@ -227,8 +231,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) |
227 | 231 | { |
228 | 232 | endpoints.MapControllerRoute("default", "{controller:slugify=Home}/{action:slugify=Index}/{id?}"); |
229 | 233 | endpoints.MapRazorPages(); |
230 | | - endpoints.MapHealthChecks("home_page_health_check"); |
231 | | - endpoints.MapHealthChecks("api_health_check"); |
| 234 | + endpoints.MapHealthChecks("home_page_health_check", new HealthCheckOptions { Predicate = check => check.Tags.Contains("homePageHealthCheck") }); |
| 235 | + endpoints.MapHealthChecks("api_health_check", new HealthCheckOptions { Predicate = check => check.Tags.Contains("apiHealthCheck") }); |
232 | 236 | //endpoints.MapBlazorHub("/admin"); |
233 | 237 | endpoints.MapFallbackToFile("index.html"); |
234 | 238 | }); |
|
0 commit comments