26 lines
731 B
C#
26 lines
731 B
C#
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace JiShe.CollectBus.Host.HealthChecks
|
|
{
|
|
public class HealthCheckResponse
|
|
{
|
|
public static Task Writer(HttpContext context, HealthReport healthReport)
|
|
{
|
|
context.Response.ContentType = "application/json";
|
|
|
|
var result = JsonConvert.SerializeObject(new
|
|
{
|
|
status = healthReport.Status.ToString(),
|
|
errors = healthReport.Entries.Select(e => new
|
|
{
|
|
key = e.Key,
|
|
value = e.Value.Status.ToString()
|
|
})
|
|
});
|
|
return context.Response.WriteAsync(result);
|
|
|
|
}
|
|
}
|
|
}
|