-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpClientsExtension.cs
More file actions
22 lines (19 loc) · 977 Bytes
/
HttpClientsExtension.cs
File metadata and controls
22 lines (19 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
namespace Comanda.Payments.WebApi.Extensions;
[ExcludeFromCodeCoverage(Justification = "contains only dependency injection registration with no business logic.")]
public static class HttpClientsExtension
{
public static void AddHttpClients(this IServiceCollection services, ISettings settings)
{
// register transient lifetime interceptors here
// https://learn.microsoft.com/en-us/aspnet/web-api/overview/advanced/httpclient-parameters-handlers
services.AddTransient<CredentialInterceptor>();
services.AddTransient<CorrelationInterceptor>();
var paymentClient = services.AddHttpClient<IAbacatePayClient, AbacatePayClient>(client =>
{
client.BaseAddress = new Uri(settings.AbacatePay.Url);
client.Timeout = TimeSpan.FromSeconds(30);
});
paymentClient.AddHttpMessageHandler<CredentialInterceptor>();
paymentClient.AddHttpMessageHandler<CorrelationInterceptor>();
}
}