elsa-core/src/clients/Elsa.Api.Client/Extensions/HeaderExtensions.cs
Sipke Schoorstra 1d21cb3733 Add extension method to get workflow instance ID
This adds a new extension method in HttpResponseMessageExtensions class which retrieves the workflow instance ID from the response. It also includes a HeaderNames class to maintain the consistency of header names used by the Elsa API.
2023-12-29 09:30:51 +01:00

14 lines
527 B
C#

using Elsa.Api.Client.Shared;
namespace Elsa.Api.Client.Extensions;
/// <summary>
/// Contains extension methods for the <see cref="HttpResponseMessage"/> class.
/// </summary>
public static class HttpResponseMessageExtensions
{
/// <summary>
/// Gets the workflow instance ID from the response.
/// </summary>
public static string? GetWorkflowInstanceId(this HttpResponseMessage response) => response.Headers.TryGetValues(HeaderNames.WorkflowInstanceId, out var values) ? values.FirstOrDefault() : default;
}