Veggerby.Ignition.Http 0.6.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Veggerby.Ignition.Http --version 0.6.0
                    
NuGet\Install-Package Veggerby.Ignition.Http -Version 0.6.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="Veggerby.Ignition.Http" Version="0.6.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Veggerby.Ignition.Http" Version="0.6.0" />
                    
Directory.Packages.props
<PackageReference Include="Veggerby.Ignition.Http" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Veggerby.Ignition.Http --version 0.6.0
                    
#r "nuget: Veggerby.Ignition.Http, 0.6.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.
#:package Veggerby.Ignition.Http@0.6.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Veggerby.Ignition.Http&version=0.6.0
                    
Install as a Cake Addin
#tool nuget:?package=Veggerby.Ignition.Http&version=0.6.0
                    
Install as a Cake Tool

Veggerby.Ignition.Http

HTTP readiness signals for Veggerby.Ignition - verify HTTP endpoints and external services during application startup.

Installation

dotnet add package Veggerby.Ignition.Http

Usage

Basic HTTP Endpoint Verification

builder.Services.AddIgnition();

builder.Services.AddHttpReadiness("https://api.example.com/health");

var app = builder.Build();
await app.Services.GetRequiredService<IIgnitionCoordinator>().WaitAllAsync();

With Custom Status Codes

builder.Services.AddHttpReadiness(
    "https://api.example.com/health",
    options =>
    {
        options.ExpectedStatusCodes = [200, 204];
        options.Timeout = TimeSpan.FromSeconds(5);
    });

With Response Validation

builder.Services.AddHttpReadiness(
    "https://api.example.com/health",
    options =>
    {
        options.ExpectedStatusCodes = [200];
        options.ValidateResponse = async (response) =>
        {
            var content = await response.Content.ReadAsStringAsync();
            return content.Contains("healthy");
        };
        options.Timeout = TimeSpan.FromSeconds(10);
    });

With Custom Headers

builder.Services.AddHttpReadiness(
    "https://api.example.com/health",
    options =>
    {
        options.CustomHeaders = new Dictionary<string, string>
        {
            ["Authorization"] = "Bearer token123",
            ["User-Agent"] = "MyApp/1.0"
        };
    });

JSON Response Validation

builder.Services.AddHttpReadiness(
    "https://api.example.com/health",
    options =>
    {
        options.ValidateResponse = async (response) =>
        {
            var json = await response.Content.ReadAsStringAsync();
            using var doc = JsonDocument.Parse(json);
            return doc.RootElement.GetProperty("status").GetString() == "healthy";
        };
    });

Features

  • HTTP Endpoint Verification: Validates connectivity to external HTTP services
  • Flexible Status Code Matching: Support for multiple expected status codes (200, 204, etc.)
  • Custom Response Validation: Validate response body content (JSON, text, etc.)
  • Custom Headers: Add Authorization, User-Agent, or other headers
  • Activity Tracing: Tags for URL, status codes, and validation results
  • Structured Logging: Information, Debug, and Error level diagnostics
  • HttpClient Reuse: Efficient connection reuse via IHttpClientFactory
  • Idempotent Execution: Cached results prevent redundant requests
  • Thread-Safe: Concurrent readiness checks execute once

Configuration Options

Property Type Description Default
Timeout TimeSpan? Per-signal timeout override null (uses global timeout)
ExpectedStatusCodes int[] HTTP status codes indicating success [200]
CustomHeaders Dictionary<string, string>? Headers to include in requests null
ValidateResponse Func<HttpResponseMessage, Task<bool>>? Custom response validation null

Logging

The signal emits structured logs at different levels:

  • Information: Request start and successful completions
  • Debug: Response received, validation execution
  • Error: Status code mismatches, validation failures, connection errors

Activity Tracing

When tracing is enabled, the signal adds these tags:

  • http.url: Target URL
  • http.expected_status_codes: Comma-separated expected status codes
  • http.status_code: Actual response status code
  • http.custom_validation: "true" if custom validation is configured

Examples

Health Check Integration

builder.Services.AddIgnition();
builder.Services.AddHttpReadiness("https://api.example.com/health");

builder.Services
    .AddHealthChecks()
    .AddCheck<IgnitionHealthCheck>("ignition-readiness");

Multiple External Services

// Primary API
builder.Services.AddHttpReadiness(
    "https://api.example.com/health",
    options =>
    {
        options.Timeout = TimeSpan.FromSeconds(5);
    });

// Payment Gateway
builder.Services.AddHttpReadiness(
    "https://payment.example.com/status",
    options =>
    {
        options.ExpectedStatusCodes = [200, 204];
        options.Timeout = TimeSpan.FromSeconds(10);
    });

Note: Currently, multiple HTTP signals will share the same name ("http-readiness"). For distinct signals, implement custom IIgnitionSignal with unique names.

Retry-After Header Handling

The signal does not automatically respect Retry-After headers. For retry logic, use Polly or similar libraries with the coordinator's timeout policies:

builder.Services.AddIgnition(options =>
{
    options.Policy = IgnitionPolicy.BestEffort;
    options.GlobalTimeout = TimeSpan.FromSeconds(30);
});

Error Handling

Connection failures and validation errors are logged and propagated:

try
{
    await coordinator.WaitAllAsync();
}
catch (AggregateException ex)
{
    foreach (var inner in ex.InnerExceptions)
    {
        if (inner is HttpRequestException httpEx)
        {
            // Handle HTTP-specific errors
            Console.WriteLine($"HTTP Error: {httpEx.Message}");
        }
        else if (inner is InvalidOperationException validationEx)
        {
            // Handle validation failures
            Console.WriteLine($"Validation Error: {validationEx.Message}");
        }
    }
}

Performance

  • Efficient HttpClient reuse via IHttpClientFactory
  • Minimal allocations per signal invocation
  • Async throughout (no blocking I/O)
  • Idempotent execution (request made once)

License

MIT License. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET 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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
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
0.6.1-prerelease0002 91 5/2/2026
0.6.1-prerelease0001 96 4/29/2026
0.6.0 124 2/2/2026
0.5.1-prerelease0023 113 2/2/2026
0.5.1-prerelease0022 113 1/26/2026
0.5.1-prerelease0021 114 1/22/2026
0.5.1-prerelease0020 111 1/22/2026
0.5.1-prerelease0019 116 1/21/2026
0.5.1-prerelease0018 109 1/21/2026
0.5.1-prerelease0017 109 1/20/2026
0.5.1-prerelease0016 116 1/20/2026
0.5.1-prerelease0014 107 1/20/2026
0.5.1-prerelease0013 120 1/20/2026
0.5.1-prerelease0011 112 1/19/2026
0.5.1-prerelease0009 113 1/19/2026
0.5.1-prerelease0008 113 1/17/2026
0.5.1-prerelease0007 116 1/16/2026
0.5.1-prerelease0006 116 1/16/2026
0.5.1-prerelease0004 119 1/16/2026
0.5.1-prerelease0003 115 1/15/2026
Loading failed