using System; using Elsa.Features.Abstractions; using Elsa.Features.Services; using Elsa.Http.Handlers; using Elsa.Http.Implementations; using Elsa.Http.Options; using Elsa.Http.Services; using Elsa.Mediator.Extensions; using Microsoft.Extensions.DependencyInjection; namespace Elsa.Http.Features; public class HttpFeature : FeatureBase { public HttpFeature(IModule module) : base(module) { } public string BasePath { get; set; } = "/workflows"; public Func HttpEndpointAuthorizationHandlerFactory { get; set; } = ActivatorUtilities.GetServiceOrCreateInstance; public Func HttpEndpointWorkflowFaultHandlerFactory { get; set; } = ActivatorUtilities.GetServiceOrCreateInstance; public HttpFeature WithBasePath(string value) { BasePath = value; return this; } public HttpFeature WithAuthorizationHandlerFactory(Func value) { HttpEndpointAuthorizationHandlerFactory = value; return this; } public HttpFeature WithWorkflowFaultHandlerFactory(Func value) { HttpEndpointWorkflowFaultHandlerFactory = value; return this; } public override void Apply() { Services.Configure(options => options.BasePath = BasePath); Services .AddSingleton() .AddSingleton() .AddNotificationHandlersFrom() .AddHttpContextAccessor(); } }