chore: implements Debug Logging for request and response including body

This commit is contained in:
Matthias Langhard
2021-06-15 11:58:40 +02:00
parent 51f464bad0
commit 14bcf19ba8
3 changed files with 52 additions and 2 deletions

View File

@@ -17,7 +17,8 @@ namespace Novaloop.PaymoApi.Extensions
{
services.Configure(options);
var resolvedOptions = (IOptions<ApiOptions>) services.BuildServiceProvider().GetService(typeof(IOptions<ApiOptions>));
services.AddHttpClient<ApiClient>(client => { client.BaseAddress = new Uri(resolvedOptions.Value.BaseUrl); });
services.AddHttpClient<ApiClient>(client => { client.BaseAddress = new Uri(resolvedOptions.Value.BaseUrl); })
.AddHttpMessageHandler(s => s.GetService<LoggingHandler>());
// ClientContacts
services.AddTransient<IBaseApi<ClientContactsResponse, ClientContact>, BaseApi<ClientContactsResponse, ClientContact>>();
@@ -31,6 +32,9 @@ namespace Novaloop.PaymoApi.Extensions
services.AddTransient<IBaseApi<ClientsResponse, Client>, BaseApi<ClientsResponse, Client>>();
services.AddTransient<IClientContactsApi, ClientContactsApi>();
// Shared
services.AddTransient<LoggingHandler>();
return services;
}
}