Tago.Extensions.Healthcheck 6.0.0

dotnet add package Tago.Extensions.Healthcheck --version 6.0.0                
NuGet\Install-Package Tago.Extensions.Healthcheck -Version 6.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tago.Extensions.Healthcheck" Version="6.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tago.Extensions.Healthcheck --version 6.0.0                
#r "nuget: Tago.Extensions.Healthcheck, 6.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Tago.Extensions.Healthcheck as a Cake Addin
#addin nuget:?package=Tago.Extensions.Healthcheck&version=6.0.0

// Install Tago.Extensions.Healthcheck as a Cake Tool
#tool nuget:?package=Tago.Extensions.Healthcheck&version=6.0.0                

Health Check Response Writer

Overview

The Health Check Response Writer is a NuGet package for C# that allows you to customize health check responses, manage routes for each endpoint, and set a parent route for all health endpoints. This package is designed to provide flexibility and control over how health check information is presented and accessed in your application.

Features

  • Customizable Responses: Tailor the health check responses to meet your specific needs.
  • Response Services: Utilize built-in services to generate health check responses.
  • Route Management: Easily manage routes for individual health check endpoints.
  • Parent Route Configuration: Set a parent route for all health endpoints to streamline access.

Installation

To install the Health Check Response Writer package, run the following command in the Package Manager Console:

Install-Package Tago.Extensions.Healthcheck

Usage

Basic Setup

  1. Add the package to your project:

    using Tago.Extensions.Healthcheck;
    
  2. Configure the health check response writer in your Program.cs / Startup.cs:

    builder.Services.AddHealthChecks()
     .WithApplicationInfo((sp, o) =>
     {
         o.Add("appName", "test");
         o.Add("environment", "test");
     })
     .AddMemoryHealthcheck(1024)
     .AddCheck<TestHealth>("test", tags: new[] { "startup" })
     //.AddHttpEndpointHealthCheck("http", new Microsoft.Extensions.Diagnostics.HealthChecks.HttpEndpointHealthCheckOptions
     //{
     //    Url = "https://tag-solutions.com",
     //    Method = HttpRequestMethods.Get,
     //    ReadResponse = false,
     //    TimeOut = TimeSpan.FromSeconds(5)
     //})    
     ;
    
      app.MapHealthCheckRoutes()
      .MapReadynessEndpoint(predicate: (reg) => {
          return reg?.Tags?.Contains("startup") != true;
      })
      .MapLivenessEndpoint()
      .MapConfiguarionEndpoint("config")
      .MapEndpoint("started", (reg) => {
          return reg?.Tags?.Contains("startup") == true;
      })
      ;
    

Customizing Responses

You can customize the health check responses by modifying the ConfigureResponse option. This allows you to format the response based on your requirements.

builder.Services.AddHealthCheckResponseWriter<MyResponseWriter>();

 app.MapHealthCheckRoutes("hc")
     .MapEndpoint<MyResponseWriter>("some-endpoint");

Setting a Parent Route

You can set a parent route for all health endpoints to make them accessible under a common path.

app.MapHealthCheckRoutes("service-health")
     .MapReadynessEndpoint("ready")
     .MapLivenessEndpoint("alive")
     ;

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.0.0 130 8/21/2024
3.1.1-preview-20240716-01 118 8/20/2024
3.1.1-preview-20240715-01 111 8/20/2024
3.1.1-preview-20240701-01 120 8/8/2024