Overview

Healthz.Api is a C# minimal API showcasing usage of health checks. The API makes usage of:

  • Registering a library health check
  • Registering a custom health check
  • Filter health checks
  • Customising output

Getting Started: ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป

Clone: โš’๏ธ

git clone https://github.com/reggieray/dotnet-health-checks

Run: ๐Ÿ‘Ÿ

Run from either two options below:

Dotnet CLI: ๐Ÿ’ป

dotnet run --project ./src/Healthz.Api/ --configuration Release

Docker: ๐Ÿ‹

docker-compose up --build

HTTP Documentation: ๐Ÿ“„

Explore HealthzApi.http and make requests with the following options available:

Example usage using httpYac:

httpyac HealthzApi.http

Test: ๐Ÿงช

dotnet test ./tests/Healthz.Api.Tests/ --configuration Release

Configuration: โš™๏ธ

Alter configuration or environment variables to change the output of the health checks.

Dotnet CLI: ๐Ÿ’ป

Alter the HealthCheck section within appsettings.Development.json and re-run.

{
  /*config removed for brevity*/
  "HealthCheck": {
    "MyCustomStartUpHealthCheck": "False",
    "UriCheck": "https://matthewregis.dev/"
  }
}

Docker: ๐Ÿ‹

Alter the environment section within docker-compose.yaml and re-run.

version: "3"
services: 
    healthzapi:
        environment:
            HealthCheck__MyCustomStartUpHealthCheck: "False"
            HealthCheck__UriCheck: "https://matthewregis.dev"
# config removed for brevity #