Browse Source

Add ApiFactory

pull/165/head
Ionite 1 year ago
parent
commit
481f13021c
No known key found for this signature in database
  1. 21
      StabilityMatrix.Core/Api/ApiFactory.cs

21
StabilityMatrix.Core/Api/ApiFactory.cs

@ -0,0 +1,21 @@
using Refit;
namespace StabilityMatrix.Core.Api;
public class ApiFactory
{
private readonly IHttpClientFactory httpClientFactory;
public RefitSettings? RefitSettings { get; init; }
public ApiFactory(IHttpClientFactory httpClientFactory)
{
this.httpClientFactory = httpClientFactory;
}
public T CreateRefitClient<T>(Uri baseAddress)
{
var httpClient = httpClientFactory.CreateClient(nameof(T));
httpClient.BaseAddress = baseAddress;
return RestService.For<T>(httpClient, RefitSettings);
}
}
Loading…
Cancel
Save