using System.Text.Json.Serialization;
using Elsa.Expressions.Models;
using Elsa.Extensions;
using Elsa.Http.Contracts;
using Elsa.Http.Models;
using Elsa.Workflows.Core;
using Elsa.Workflows.Core.Attributes;
using Elsa.Workflows.Core.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Primitives;
namespace Elsa.Http;
///
/// Wait for an inbound HTTP request that matches the specified path and methods.
///
[Activity("Elsa", "HTTP", "Wait for an inbound HTTP request that matches the specified path and methods.", DisplayName = "HTTP Endpoint")]
public class HttpEndpoint : Trigger
{
internal const string HttpContextInputKey = "HttpContext";
internal const string RequestPathInputKey = "RequestPath";
///
[JsonConstructor]
public HttpEndpoint()
{
}
///
/// The path to associate with the workflow.
///
[Input(Description = "The path to associate with the workflow.")]
public Input Path { get; set; } = default!;
///
/// The HTTP methods to accept.
///
[Input(
Description = "The HTTP methods to accept.",
Options = new[] { "GET", "POST", "PUT", "HEAD", "DELETE" },
UIHint = InputUIHints.CheckList)]
public Input> SupportedMethods { get; set; } = new(ObjectLiteral.From(new[] { HttpMethods.Get }));
///
/// Allow authenticated requests only.
///
[Input(Description = "Allow authenticated requests only.", Category = "Security")]
public Input Authorize { get; set; } = new(false);
///
/// Provide a policy to evaluate. If the policy fails, the request is forbidden.
///
[Input(Description = "Provide a policy to evaluate. If the policy fails, the request is forbidden.", Category = "Security")]
public Input Policy { get; set; } = new(default(string?));
///
/// The parsed request content, if any.
///
[Output(Description = "The parsed request content, if any.")]
public Output