mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
minor DI registration cleanup
This commit is contained in:
parent
b9d39be154
commit
7a7ad3a160
1 changed files with 4 additions and 10 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue