Refactor and expose more information
This commit was merged in pull request #1.
This commit is contained in:
17
HomeApi/Extensions/IntegrationExtensions.cs
Normal file
17
HomeApi/Extensions/IntegrationExtensions.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using HomeApi.Models.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace HomeApi.Extensions;
|
||||
|
||||
public static class IntegrationExtensions
|
||||
{
|
||||
public static void ConfigureBaseAddress(this IHttpClientBuilder builder,
|
||||
Func<ApiConfiguration, string> getBaseUrl)
|
||||
{
|
||||
builder.ConfigureHttpClient((serviceProvider, client) =>
|
||||
{
|
||||
var config = serviceProvider.GetRequiredService<IOptions<ApiConfiguration>>().Value;
|
||||
client.BaseAddress = new Uri(getBaseUrl(config));
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user