Update API client
This commit is contained in:
parent
10a71d3049
commit
c429fe6fcc
|
|
@ -32,7 +32,7 @@ public static class DependencyInjectionExtensions
|
|||
public static IServiceCollection AddElsaClient(this IServiceCollection services, Action<ElsaClientOptions> configureOptions)
|
||||
{
|
||||
services.Configure(configureOptions);
|
||||
services.AddSingleton<IElsaClient, ElsaClient>();
|
||||
services.AddScoped<IElsaClient, ElsaClient>();
|
||||
services.AddActivityTypeService();
|
||||
|
||||
services.AddApi<IWorkflowDefinitionsApi>(CreateRefitSettings);
|
||||
|
|
@ -71,6 +71,7 @@ public static class DependencyInjectionExtensions
|
|||
{
|
||||
var options = serviceProvider.GetRequiredService<IOptions<ElsaClientOptions>>().Value;
|
||||
httpClient.BaseAddress = options.BaseAddress;
|
||||
options.ConfigureHttpClient?.Invoke(httpClient);
|
||||
}
|
||||
|
||||
private static RefitSettings CreateRefitSettings(IServiceProvider serviceProvider)
|
||||
|
|
|
|||
|
|
@ -14,4 +14,9 @@ public class ElsaClientOptions
|
|||
/// Gets or sets the API key to use when authenticating with the Elsa server.
|
||||
/// </summary>
|
||||
public string ApiKey { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a delegate that can be used to configure the HTTP client.
|
||||
/// </summary>
|
||||
public Action<HttpClient>? ConfigureHttpClient { get; set; }
|
||||
}
|
||||
Loading…
Reference in a new issue