-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
dc223bc
commit 1d21cb3
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
src/clients/Elsa.Api.Client/Extensions/HeaderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} |