Table of Contents

Class GovernanceHttpRequestCorrelation

Namespace
AsiBackbone.AspNetCore.Correlation
Assembly
AsiBackbone.AspNetCore.dll

Represents framework-neutral request correlation data resolved from the current ASP.NET Core HTTP request.

public sealed class GovernanceHttpRequestCorrelation
Inheritance
GovernanceHttpRequestCorrelation
Inherited Members
Extension Methods

Remarks

Initializes a new instance of the GovernanceHttpRequestCorrelation class.

Constructors

GovernanceHttpRequestCorrelation(string?, string?, IReadOnlyDictionary<string, string>?)

Represents framework-neutral request correlation data resolved from the current ASP.NET Core HTTP request.

public GovernanceHttpRequestCorrelation(string? correlationId = null, string? traceId = null, IReadOnlyDictionary<string, string>? metadata = null)

Parameters

correlationId string

The resolved correlation identifier, when available.

traceId string

The resolved trace identifier, when available.

metadata IReadOnlyDictionary<string, string>

Safe request metadata resolved from the host.

Remarks

Initializes a new instance of the GovernanceHttpRequestCorrelation class.

Properties

CorrelationId

Gets the request correlation identifier, when supplied by the host or propagated request headers.

public string? CorrelationId { get; }

Property Value

string

HasMetadata

Gets a value indicating whether safe request metadata is available.

public bool HasMetadata { get; }

Property Value

bool

Metadata

Gets safe request metadata supplied by the ASP.NET Core adapter.

public IReadOnlyDictionary<string, string> Metadata { get; }

Property Value

IReadOnlyDictionary<string, string>

TraceId

Gets the request trace identifier, when supplied by the host or current activity.

public string? TraceId { get; }

Property Value

string

Methods

MergeMetadata(IReadOnlyDictionary<string, string>?)

Merges safe request metadata with host-provided metadata.

public IReadOnlyDictionary<string, string> MergeMetadata(IReadOnlyDictionary<string, string>? metadata)

Parameters

metadata IReadOnlyDictionary<string, string>

Optional host-provided metadata.

Returns

IReadOnlyDictionary<string, string>

A normalized metadata dictionary.

ToEvaluationContext(string?, string?, IReadOnlyDictionary<string, string>?, bool)

Creates a framework-neutral constraint evaluation context from the resolved request correlation data.

public GovernanceEvaluationContext ToEvaluationContext(string? policyVersion = null, string? policyHash = null, IReadOnlyDictionary<string, string>? metadata = null, bool mergeRequestMetadata = true)

Parameters

policyVersion string

Optional policy version.

policyHash string

Optional policy hash.

metadata IReadOnlyDictionary<string, string>

Optional host-provided metadata to merge with safe request metadata.

mergeRequestMetadata bool

When true (the default), Metadata is merged underneath metadata. Pass false when metadata already contains request metadata and is authoritative — for example after sanitization, where re-merging would reintroduce entries the sanitizer removed. metadata is still key-normalized either way.

Returns

GovernanceEvaluationContext

A framework-neutral constraint evaluation context.

Remarks

Merging layers metadata over Metadata by key, so a caller that rewrites a request-derived value overrides it, but a caller that removes one does not: with nothing to override the raw entry, the merge puts it back. Sanitized metadata must therefore be passed with mergeRequestMetadata set to false.