refactor(IHttpClientOptions): removed

This commit is contained in:
Developer 02 2024-11-25 10:42:22 +01:00
parent c65eefb954
commit 3b8b315fea
5 changed files with 8 additions and 23 deletions

View File

@ -1,13 +0,0 @@
namespace DigitalData.Core.Abstractions.Client
{
public interface IHttpClientOptions
{
string Uri { get; init; }
string? Path { get; init; }
IEnumerable<KeyValuePair<string, object>>? Headers { get; init; }
IEnumerable<KeyValuePair<string, object?>>? QueryParams { get; init; }
}
}

View File

@ -1,6 +1,6 @@
namespace DigitalData.Core.Abstractions.Client
{
public interface IHttpClientService<TClientOptions> : IBaseHttpClientService where TClientOptions : IHttpClientOptions
public interface IHttpClientService<TClientOptions> : IBaseHttpClientService
{
}
}

View File

@ -8,7 +8,7 @@ namespace DigitalData.Core.Client
{
public static class DIExtensions
{
public static IServiceCollection AddHttpClientService(this IServiceCollection services, IConfigurationSection? section)
public static IServiceCollection AddHttpClientService(this IServiceCollection services, IConfigurationSection? section = null)
{
services.TryAddSingleton<HttpClient>();
services.TryAddSingleton<CookieContainer>();

View File

@ -1,15 +1,13 @@
using DigitalData.Core.Abstractions.Client;
namespace DigitalData.Core.Client
namespace DigitalData.Core.Client
{
public class HttpClientOptions : IHttpClientOptions
public class HttpClientOptions
{
public required string Uri { get; init; }
public string? Path { get; init; }
public string? Path { get; init; } = null;
public IEnumerable<KeyValuePair<string, object>>? Headers { get; init; }
public IEnumerable<KeyValuePair<string, object>>? Headers { get; init; } = null;
public IEnumerable<KeyValuePair<string, object?>>? QueryParams { get; init; }
public IEnumerable<KeyValuePair<string, object?>>? QueryParams { get; init; } = null;
}
}

View File

@ -19,7 +19,7 @@ namespace DigitalData.Core.Client
public static T Provide<T>() where T : notnull => _lazyProvider.Value.GetRequiredService<T>();
public static IHttpClientService<TOptions> ProvideHttpClientService<TOptions>() where TOptions : IHttpClientOptions
public static IHttpClientService<TOptions> ProvideHttpClientService<TOptions>()
=> _lazyProvider.Value.GetRequiredService<IHttpClientService<TOptions>>();
}
}