Update HttpEndpoint to not block when input is received
This commit is contained in:
parent
37843a7de4
commit
5b7bc894f0
|
|
@ -2,6 +2,7 @@
|
|||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using Elsa.Attributes;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Management.Models;
|
||||
using Elsa.Models;
|
||||
using Elsa.Modules.Http.Models;
|
||||
|
|
@ -10,6 +11,8 @@ namespace Elsa.Modules.Http;
|
|||
|
||||
public class HttpEndpoint : Trigger
|
||||
{
|
||||
public const string InputKey = "HttpRequest";
|
||||
|
||||
[Input] public Input<string> Path { get; set; } = default!;
|
||||
|
||||
[Input(
|
||||
|
|
@ -18,10 +21,22 @@ public class HttpEndpoint : Trigger
|
|||
)]
|
||||
public Input<ICollection<string>> SupportedMethods { get; set; } = new(new[] { HttpMethod.Get.Method });
|
||||
|
||||
[Output] public Output<HttpRequestModel>? Result { get; set; }
|
||||
[Output] public Output<HttpRequestModel>? Request { get; set; }
|
||||
|
||||
protected override IEnumerable<object> GetTriggerData(TriggerIndexingContext context) => GetBookmarkData(context.ExpressionExecutionContext);
|
||||
protected override void Execute(ActivityExecutionContext context) => context.SetBookmarks(GetBookmarkData(context.ExpressionExecutionContext));
|
||||
protected override void Execute(ActivityExecutionContext context)
|
||||
{
|
||||
// If we did not receive external input, it means we are just now encountering this activity.
|
||||
if (!context.TryGetInput<HttpRequestModel>(InputKey, out var request ))
|
||||
{
|
||||
// Create bookmarks for when we receive the expected HTTP request.
|
||||
context.CreateBookmarks(GetBookmarkData(context.ExpressionExecutionContext));
|
||||
return;
|
||||
}
|
||||
|
||||
// Provide the received HTTP request as output.
|
||||
context.Set(Request, request);
|
||||
}
|
||||
|
||||
private IEnumerable<object> GetBookmarkData(ExpressionExecutionContext context)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue