From c429fe6fccdd86d936ec17efd4723b715077cbc2 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Mon, 31 Jul 2023 22:37:57 +0200 Subject: [PATCH] Update API client --- .../Extensions/DependencyInjectionExtensions.cs | 3 ++- src/clients/Elsa.Api.Client/Options/ElsaClientOptions.cs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/clients/Elsa.Api.Client/Extensions/DependencyInjectionExtensions.cs b/src/clients/Elsa.Api.Client/Extensions/DependencyInjectionExtensions.cs index 4c87a894a..cd6c9f647 100644 --- a/src/clients/Elsa.Api.Client/Extensions/DependencyInjectionExtensions.cs +++ b/src/clients/Elsa.Api.Client/Extensions/DependencyInjectionExtensions.cs @@ -32,7 +32,7 @@ public static class DependencyInjectionExtensions public static IServiceCollection AddElsaClient(this IServiceCollection services, Action configureOptions) { services.Configure(configureOptions); - services.AddSingleton(); + services.AddScoped(); services.AddActivityTypeService(); services.AddApi(CreateRefitSettings); @@ -71,6 +71,7 @@ public static class DependencyInjectionExtensions { var options = serviceProvider.GetRequiredService>().Value; httpClient.BaseAddress = options.BaseAddress; + options.ConfigureHttpClient?.Invoke(httpClient); } private static RefitSettings CreateRefitSettings(IServiceProvider serviceProvider) diff --git a/src/clients/Elsa.Api.Client/Options/ElsaClientOptions.cs b/src/clients/Elsa.Api.Client/Options/ElsaClientOptions.cs index 284ce4945..5dd5ccb64 100644 --- a/src/clients/Elsa.Api.Client/Options/ElsaClientOptions.cs +++ b/src/clients/Elsa.Api.Client/Options/ElsaClientOptions.cs @@ -14,4 +14,9 @@ public class ElsaClientOptions /// Gets or sets the API key to use when authenticating with the Elsa server. /// public string ApiKey { get; set; } = default!; + + /// + /// Gets or sets a delegate that can be used to configure the HTTP client. + /// + public Action? ConfigureHttpClient { get; set; } } \ No newline at end of file