// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Diagnostics.HealthChecks; namespace Microsoft.AspNetCore.Diagnostics.HealthChecks { /// /// Contains options for the . /// public class HealthCheckOptions { /// /// Gets or sets a predicate that is used to filter the set of health checks executed. /// /// /// If is null, the will run all /// registered health checks - this is the default behavior. To run a subset of health checks, /// provide a function that filters the set of checks. /// public Func Predicate { get; set; } /// /// Gets a dictionary mapping the to an HTTP status code applied to the response. /// This property can be used to configure the status codes returned for each status. /// public IDictionary ResultStatusCodes { get; } = new Dictionary() { { HealthStatus.Healthy, StatusCodes.Status200OK }, { HealthStatus.Degraded, StatusCodes.Status200OK }, { HealthStatus.Unhealthy, StatusCodes.Status503ServiceUnavailable }, // This means that a health check failed, so 500 is appropriate. This is an error. { HealthStatus.Failed, StatusCodes.Status500InternalServerError }, }; /// /// Gets or sets a delegate used to write the response. /// /// /// The default value is a delegate that will write a minimal text/plain response with the value /// of as a string. /// public Func ResponseWriter { get; set; } = HealthCheckResponseWriters.WriteMinimalPlaintext; } }