You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
565 B
22 lines
565 B
1 year ago
|
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);
|
||
|
}
|
||
|
}
|