elsa-core/src/modules/Elsa.Http/UIHints/HttpEndpointPathUIHandler.cs
Sipke Schoorstra 08e0f8ed16
Refactor URL trimming logic in HTTP endpoint handlers (#6141)
Updated the URL trimming logic to ensure consistent handling of base URLs and paths, removing trailing slashes where necessary. This change improves the consistency and reliability of URL generation.
2024-11-22 21:30:41 +01:00

28 lines
915 B
C#

using System.Reflection;
using Elsa.Workflows;
using Elsa.Workflows.UIHints;
using Elsa.Workflows.UIHints.SingleLine;
namespace Elsa.Http.UIHints;
/// <summary>
/// Provides additional options for the Path input field.
/// </summary>
public class HttpEndpointPathUIHandler(IHttpEndpointBasePathProvider httpEndpointBasePathProvider) : IPropertyUIHandler
{
/// <inheritdoc />
public ValueTask<IDictionary<string, object>> GetUIPropertiesAsync(PropertyInfo propertyInfo, object? context, CancellationToken cancellationToken = default)
{
var completeBaseUrl = httpEndpointBasePathProvider.GetBasePath();
return new(new Dictionary<string, object>
{
[InputUIHints.SingleLine] = new SingleLineProps
{
AdornmentText = completeBaseUrl,
EnableCopyAdornment = true
},
["Refresh"] = true
});
}
}