HttpClientBuilderExtensions
Namespace: RA.Utilities.Integrations.Extensions
The HttpClientBuilderExtensions class provides extension members on IHttpClientBuilder (declared inside an extension(IHttpClientBuilder) block) that attach DelegatingHandlers to a typed client's message handler pipeline.
Chain them directly off AddHttpClientIntegration(...).
AddLoggingHandler()
Adds the LoggingHandler to the pipeline, which logs the details of every outgoing request and its response as structured logs.
Parameters
| Parameter | Type | Description |
|---|---|---|
httpClientBuilder | IHttpClientBuilder | The builder to configure. |
| Returns | IHttpClientBuilder | The original builder for chaining. |
Example
// In Program.cs
builder.Services.AddHttpClientIntegration<IMyApiClient, MyApiClient, MyApiSettings>(
builder.Configuration.GetSection("MyApi"))
.AddLoggingHandler();
AddInternalHeadersForwardingHandler()
Adds the InternalHeadersForwardHandler to the pipeline, which forwards the current request's Authorization token and x-request-id (or TraceIdentifier fallback) to every outgoing call — see the handler page for details.
Parameters
| Parameter | Type | Description |
|---|---|---|
httpClientBuilder | IHttpClientBuilder | The builder to configure. |
| Returns | IHttpClientBuilder | The original builder for chaining. |
Example
// In Program.cs
builder.Services.AddHttpClientIntegration<IMyApiClient, MyApiClient, MyApiSettings>(
builder.Configuration.GetSection("MyApi"))
.AddInternalHeadersForwardingHandler();
These methods replace the v10.1.1 WithHttpLoggingHandler() and WithInternalHeadersForwardingHandler() extension methods from DependencyInjectionExtensions. The handler attachments are equivalent — AddLoggingHandler() attaches the handler formerly known as RequestResponseLoggingHandler (now LoggingHandler) — only the method names changed; see the migration guide.