using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; namespace Yi.Framework.WebCore.MiddlewareExtend { /// /// 健康检测扩展 /// public static class HealthCheckExtension { /// /// 设置心跳响应 /// /// /// 默认是/Health /// public static void UseHealthCheckService(this IApplicationBuilder app, string checkPath = "/Health") { if (Appsettings.appBool("HealthCheck_Enabled")) { app.Map(checkPath, applicationBuilder => applicationBuilder.Run(async context => { Console.WriteLine($"This is Health Check"); context.Response.StatusCode = (int)HttpStatusCode.OK; await context.Response.WriteAsync("OK"); })); } } } }