* Await HTTP resume callbacks * Update HttpEndpoint.cs * Update HttpEndpointActivityExecutionContextExtensions.cs * Refactor to use `WaitForHttpRequestAsync` consistently. Replaced `WaitForHttpRequest` with `WaitForHttpRequestAsync` across the codebase to align with asynchronous naming conventions. This change improves clarity and maintains consistency in method naming. * Add 'codex/*' branch to workflow path filters This update ensures that actions in the workflow are triggered for changes in branches following the 'codex/*' naming convention. It aligns the path filters with the branching strategy and improves CI/CD coverage.
42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using Elsa.Http.Extensions;
|
|
using Elsa.Workflows;
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
namespace Elsa.Http;
|
|
|
|
public abstract class HttpEndpointBase : HttpEndpointBase<object>;
|
|
|
|
public abstract class HttpEndpointBase<TResult> : Trigger<TResult>
|
|
{
|
|
protected abstract HttpEndpointOptions GetOptions();
|
|
|
|
protected virtual ValueTask OnHttpRequestReceivedAsync(ActivityExecutionContext activityExecutionContext, HttpContext httpContext)
|
|
{
|
|
OnHttpRequestReceived(activityExecutionContext, httpContext);
|
|
return default;
|
|
}
|
|
|
|
protected virtual void OnHttpRequestReceived(ActivityExecutionContext activityExecutionContext, HttpContext httpContext)
|
|
{
|
|
}
|
|
|
|
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
|
|
{
|
|
var options = GetOptions();
|
|
await context.WaitForHttpRequestAsync(options, HttpRequestReceivedAsync);
|
|
}
|
|
|
|
protected override IEnumerable<object> GetTriggerPayloads(TriggerIndexingContext context)
|
|
{
|
|
var options = GetOptions();
|
|
context.TriggerName = HttpStimulusNames.HttpEndpoint;
|
|
return context.GetHttpEndpointStimuli(options);
|
|
}
|
|
|
|
private async ValueTask HttpRequestReceivedAsync(ActivityExecutionContext context)
|
|
{
|
|
var httpContext = context.GetRequiredService<IHttpContextAccessor>().HttpContext!;
|
|
await OnHttpRequestReceivedAsync(context, httpContext);
|
|
await context.CompleteActivityAsync();
|
|
}
|
|
} |