Skip to content

Commit

Permalink
Add extension method to get workflow instance ID
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sfmskywalker committed Dec 29, 2023
1 parent dc223bc commit 1d21cb3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/clients/Elsa.Api.Client/Extensions/HeaderExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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;
}
12 changes: 12 additions & 0 deletions src/clients/Elsa.Api.Client/Shared/HeaderNames.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Elsa.Api.Client.Shared;

/// <summary>
/// Contains header names used by the Elsa API.
/// </summary>
public static class HeaderNames
{
/// <summary>
/// The name of the header that contains the workflow instance ID.
/// </summary>
public const string WorkflowInstanceId = "x-elsa-workflow-instance-id";
}

0 comments on commit 1d21cb3

Please sign in to comment.