public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews()
.Services
.AddHealthChecks(Configuration);
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
endpoints.MapHealthChecks("/health", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
});
}
static class ServiceCollectionExtensions
{
public static IServiceCollection AddHealthChecks(this IServiceCollection services, IConfiguration configuration)
{
services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy());
//.AddUrlGroup(new Uri(configuration["IdentityUrlHC"]), name: "identityapi-check", tags: new string[] { "identityapi" });
return services;
}
}
直接请求链接:http://localhost:8888/health
标签:健康检查,AddHealthChecks,IServiceCollection,static,new,services,net6,public From: https://www.cnblogs.com/caihuaxing/p/16587357.html