Skip to content

Commit

Permalink
SWA
Browse files Browse the repository at this point in the history
  • Loading branch information
CuteLeon committed Sep 6, 2023
1 parent db15031 commit 2ada155
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ namespace CleanMicroserviceSystem.Aphrodite.Infrastructure;

public static class DependencyInjection
{
private const string NuGetServerConfigurationKey = "NuGetServerConfiguration";
private const string GatewayAPIConfigurationKey = "GatewayAPIConfiguration";

public static IServiceCollection ConfigureServices(this WebAssemblyHostBuilder builder)
{
var config = builder.Configuration;
Expand Down Expand Up @@ -51,20 +48,21 @@ public static IServiceCollection ConfigureServices(this WebAssemblyHostBuilder b
ApiContract.AphroditeHttpClientName,
client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress));
_ = services
.Configure<GatewayAPIConfiguration>(options => config.GetRequiredSection(GatewayAPIConfigurationKey).Bind(options))
.Configure<GatewayAPIConfiguration>(options => config.GetRequiredSection(GatewayAPIConfiguration.ConfigurationKey).Bind(options))
.Configure<AppearanceConfiguration>(options => config.GetRequiredSection(AppearanceConfiguration.ConfigurationKey).Bind(options))
.AddThemisClients(options =>
{
options.GatewayClientName = ApiContract.GatewayHttpClientName;
})
.AddAstraClients(options =>
{
options.GatewayClientName = ApiContract.GatewayHttpClientName;
options.ApiKey = config.GetRequiredSection(NuGetServerConfigurationKey)!.Get<NuGetServerConfiguration>()!.ApiKey;
options.ApiKey = config.GetRequiredSection(NuGetServerConfiguration.ConfigurationKey)!.Get<NuGetServerConfiguration>()!.ApiKey;
})
.AddTransient<DefaultAuthenticationDelegatingHandler>()
.AddHttpClient<HttpClient>(
ApiContract.GatewayHttpClientName,
client => client.BaseAddress = new Uri(config.GetRequiredSection(GatewayAPIConfigurationKey).Get<GatewayAPIConfiguration>()!.GatewayBaseAddress))
client => client.BaseAddress = new Uri(config.GetRequiredSection(GatewayAPIConfiguration.ConfigurationKey).Get<GatewayAPIConfiguration>()!.GatewayBaseAddress))
.AddHttpMessageHandler<DefaultAuthenticationDelegatingHandler>();
return services;
}
Expand Down

0 comments on commit 2ada155

Please sign in to comment.