minor DI registration cleanup

This commit is contained in:
Collin M. Barrett 2019-07-08 16:56:26 -05:00
parent b9d39be154
commit 7a7ad3a160

View file

@ -73,7 +73,7 @@ private static void AddLoggingCustom(this IServiceCollection services)
private static void AddApiClient(this IServiceCollection services)
{
services.AddSingleton<IRestClient>(b =>
services.AddSingleton<IRestClient, RestClient>(b =>
{
var filterListsApiSettings = b.GetService<IOptions<FilterListsApiSettings>>().Value;
return new RestClient(filterListsApiSettings.BaseUrl) {UserAgent = "FilterLists.Agent"};
@ -107,15 +107,9 @@ private static void AddUrlRepository(this IServiceCollection services)
private static void AddListRepository(this IServiceCollection services)
{
services.AddHttpClient<IListRepository, ListRepository>()
.ConfigureHttpMessageHandlerBuilder(b =>
{
b.PrimaryHandler = new HttpClientHandler {AllowAutoRedirect = false};
b.Build();
})
.AddTransientHttpErrorPolicy(b =>
b.OrResult(r => r.StatusCode == HttpStatusCode.TooManyRequests)
.WaitAndRetryAsync(5, i => i * TimeSpan.FromSeconds(3)));
services.AddHttpClient<IListRepository, ListRepository>().AddTransientHttpErrorPolicy(b =>
b.OrResult(r => r.StatusCode == HttpStatusCode.TooManyRequests)
.WaitAndRetryAsync(5, i => i * TimeSpan.FromSeconds(3)));
}
private static void AddArchiveRepository(this IServiceCollection services)