refactor(HttpClientOptions): entfernt und durch IHttpClientOptions mit Klasseneinschränkung ersetzt
This commit is contained in:
parent
f602a842be
commit
ef7da0e52c
@ -19,7 +19,7 @@ namespace DigitalData.Core.Client
|
||||
|
||||
protected IEnumerable<KeyValuePair<string, object?>>? _queryParams;
|
||||
|
||||
public BaseHttpClientService(HttpClient client, CookieContainer cookieContainer, HttpClientOptions clientOptions)
|
||||
public BaseHttpClientService(HttpClient client, CookieContainer cookieContainer, IHttpClientOptions clientOptions)
|
||||
{
|
||||
_client = client;
|
||||
_cookies = cookieContainer;
|
||||
|
||||
@ -9,7 +9,7 @@ namespace DigitalData.Core.Client
|
||||
public static class DIExtensions
|
||||
{
|
||||
public static IServiceCollection AddHttpClientService<THttpClientOptions>(this IServiceCollection services, IConfigurationSection? section = null)
|
||||
where THttpClientOptions : HttpClientOptions
|
||||
where THttpClientOptions : class, IHttpClientOptions
|
||||
{
|
||||
services.TryAddSingleton<HttpClient>();
|
||||
services.TryAddSingleton<CookieContainer>();
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
using DigitalData.Core.Abstractions.Client;
|
||||
|
||||
namespace DigitalData.Core.Client
|
||||
{
|
||||
public class HttpClientOptions : IHttpClientOptions
|
||||
{
|
||||
public required string Uri { get; init; }
|
||||
|
||||
public string? Path { get; init; }
|
||||
|
||||
public IEnumerable<KeyValuePair<string, object>>? Headers { get; init; }
|
||||
|
||||
public IEnumerable<KeyValuePair<string, object?>>? QueryParams { get; init; }
|
||||
}
|
||||
}
|
||||
@ -5,7 +5,7 @@ using System.Net;
|
||||
namespace DigitalData.Core.Client
|
||||
{
|
||||
public class HttpClientService<TClientOptions> : BaseHttpClientService, IHttpClientService<TClientOptions>, IBaseHttpClientService
|
||||
where TClientOptions : HttpClientOptions
|
||||
where TClientOptions : class, IHttpClientOptions
|
||||
{
|
||||
public HttpClientService(HttpClient client, CookieContainer cookieContainer, IOptions<TClientOptions> clientOptions) : base(client, cookieContainer, clientOptions.Value)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user