首页 > 其他分享 >.net6 健康检查

.net6 健康检查

时间:2022-08-15 10:37:20浏览次数:46  
标签:健康检查 AddHealthChecks IServiceCollection static new services net6 public


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

相关文章

  • .Net6 Html.Action无法使用(ViewComponents)
    接触了netcore的小伙伴们已经发现@html.Action()方法官方已经不提供支持了,转而使用 ViewComponents替代了,同时也增加了TagHelper。1.如果想用以前的@Html.Action()......