< Summary

Information
Class: AsiBackbone.AspNetCore.DependencyInjection.AsiBackboneAspNetCoreOptions
Assembly: AsiBackbone.AspNetCore
File(s): /home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.AspNetCore/DependencyInjection/AsiBackboneAspNetCoreOptions.cs
Line coverage
100%
Covered lines: 22
Uncovered lines: 0
Coverable lines: 22
Total lines: 86
Line coverage: 100%
Branch coverage
100%
Covered branches: 10
Total branches: 10
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.AspNetCore/DependencyInjection/AsiBackboneAspNetCoreOptions.cs

#LineLine coverage
 1namespace AsiBackbone.AspNetCore.DependencyInjection;
 2
 3/// <summary>
 4/// Provides configuration options for ASP.NET Core host integration.
 5/// </summary>
 6public sealed class AsiBackboneAspNetCoreOptions
 7{
 8    /// <summary>
 9    /// Gets the default header names checked for correlation identifier propagation.
 10    /// </summary>
 9411    public static IReadOnlyList<string> DefaultCorrelationIdHeaderNames { get; } =
 312    [
 313        "X-Correlation-ID",
 314        "X-Request-ID",
 315        "Traceparent",
 316    ];
 17
 18    /// <summary>
 19    /// Gets or sets a value indicating whether HTTP route values may be included by request-context adapters.
 20    /// </summary>
 13921    public bool IncludeRouteValues { get; set; } = true;
 22
 23    /// <summary>
 24    /// Gets or sets a value indicating whether endpoint metadata may be inspected by request-context adapters.
 25    /// </summary>
 26    public bool IncludeEndpointMetadata
 27    {
 1028        get => IncludeEndpointDisplayName || IncludeRoutePattern;
 29        set
 30        {
 1031            IncludeEndpointDisplayName = value;
 1032            IncludeRoutePattern = value;
 1033        }
 34    }
 35
 36    /// <summary>
 37    /// Gets or sets a value indicating whether the HTTP method may be included as safe audit metadata.
 38    /// </summary>
 13939    public bool IncludeRequestMethod { get; set; } = true;
 40
 41    /// <summary>
 42    /// Gets or sets a value indicating whether the HTTP path may be included as safe audit metadata.
 43    /// </summary>
 4544    public bool IncludeRequestPath { get; set; }
 45
 46    /// <summary>
 47    /// Gets or sets a value indicating whether endpoint display names may be included as safe audit metadata.
 48    /// </summary>
 15949    public bool IncludeEndpointDisplayName { get; set; } = true;
 50
 51    /// <summary>
 52    /// Gets or sets a value indicating whether endpoint route patterns may be included as safe audit metadata.
 53    /// </summary>
 15354    public bool IncludeRoutePattern { get; set; } = true;
 55
 56    /// <summary>
 57    /// Gets or sets a value indicating whether the ASP.NET Core trace identifier is used as the correlation identifier
 58    /// when no configured correlation header is present.
 59    /// </summary>
 13360    public bool UseHttpContextTraceIdentifierAsCorrelationId { get; set; } = true;
 61
 62    /// <summary>
 63    /// Gets or sets the primary HTTP header name preferred for correlation identifier propagation.
 64    /// </summary>
 65    public string CorrelationIdHeaderName
 66    {
 867        get => CorrelationIdHeaderNames.FirstOrDefault() ?? string.Empty;
 1268        set => CorrelationIdHeaderNames = [value];
 69    }
 70
 71    /// <summary>
 72    /// Gets or sets the HTTP header names checked for correlation identifier propagation.
 73    /// </summary>
 45674    public IList<string> CorrelationIdHeaderNames { get; set; } = [.. DefaultCorrelationIdHeaderNames];
 75
 76    /// <summary>
 77    /// Validates the options.
 78    /// </summary>
 79    public void Validate()
 80    {
 9781        if (CorrelationIdHeaderNames is null || CorrelationIdHeaderNames.Count == 0 || CorrelationIdHeaderNames.All(stri
 82        {
 1283            throw new InvalidOperationException("At least one correlation identifier header name must be configured.");
 84        }
 8585    }
 86}