feat(EConnectClientOptions): created and inject
This commit is contained in:
parent
c6ec3ca054
commit
2e59c090a8
@ -1,17 +1,21 @@
|
||||
using Leanetec.EConnect.Client.Interface;
|
||||
using Leanetec.EConnect.Domain.Entities;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Net.Http.Json;
|
||||
|
||||
namespace Leanetec.EConnect.Infrastructure;
|
||||
|
||||
public class EConnectClient<TError> : IEConnectClient<TError> where TError : class
|
||||
{
|
||||
private readonly EConnectClientOptions _options;
|
||||
|
||||
private readonly Lazy<HttpClient> LazyHttp;
|
||||
|
||||
private HttpClient Http => LazyHttp.Value;
|
||||
|
||||
public EConnectClient(IHttpClientFactory httpFactory)
|
||||
public EConnectClient(IOptions<EConnectClientOptions> options, IHttpClientFactory httpFactory)
|
||||
{
|
||||
_options = options.Value;
|
||||
LazyHttp = new Lazy<HttpClient>(httpFactory.CreateEConnectClient);
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
namespace Leanetec.EConnect.Infrastructure;
|
||||
|
||||
public class EConnectClientOptions
|
||||
{
|
||||
public string? ApiKey { get; set; }
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user