Skip to content

Instantly share code, notes, and snippets.

@ntakouris
Created September 10, 2019 14:47
Show Gist options
  • Save ntakouris/446f60c1aa6b9ff7ea0f94ad488de98c to your computer and use it in GitHub Desktop.
Save ntakouris/446f60c1aa6b9ff7ea0f94ad488de98c to your computer and use it in GitHub Desktop.
app.UseHealthChecks("/health", new HealthCheckOptions
{
ResponseWriter = async (context, report) =>
{
context.Response.ContentType = "application/json";
var response = new HealthCheckResponse
{
Status = report.Status.ToString(),
Checks = report.Entries.Select(x => new HealthCheck
{
Component = x.Key,
Status = x.Value.Status.ToString(),
Description = x.Value.Description
}),
Duration = report.TotalDuration
};
await context.Response.WriteAsync(JsonConvert.SerializeObject(response));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment