Class CorrelationIdHandler
A DelegatingHandler that forwards the ambient correlation id on outbound HTTP
calls. Attach it to any HttpClient (via IHttpClientBuilder.AddQuilt4NetCorrelationId())
whose target should receive the same X-Correlation-ID as the current request — letting
one id span the consuming app, the services it calls, and Quilt4Net.Server.
public sealed class CorrelationIdHandler : DelegatingHandler, IDisposable
- Inheritance
-
CorrelationIdHandler
- Implements
- Inherited Members
Remarks
No-op when there is no ambient id (Current is null/empty) or when the request already carries the header — so an explicitly-set id is never overwritten.
Constructors
CorrelationIdHandler(ICorrelationIdAccessor)
public CorrelationIdHandler(ICorrelationIdAccessor accessor)
Parameters
accessorICorrelationIdAccessor
Methods
SendAsync(HttpRequestMessage, CancellationToken)
Sends an HTTP request to the inner handler to send to the server as an asynchronous operation.
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
Parameters
requestHttpRequestMessageThe HTTP request message to send to the server.
cancellationTokenCancellationTokenA cancellation token to cancel operation.
Returns
- Task<HttpResponseMessage>
The task object representing the asynchronous operation.
Exceptions
- ArgumentNullException
The
requestwas null.