parent
a0a0482f5d
commit
8c40475cc6
|
|
@ -53,7 +53,6 @@ public class HttpWorkflowsMiddleware(RequestDelegate next, ITenantAccessor tenan
|
|||
}
|
||||
|
||||
// Strip the base path.
|
||||
path = path[basePath.Length..];
|
||||
matchingPath = matchingPath[basePath.Length..];
|
||||
}
|
||||
|
||||
|
|
@ -62,7 +61,7 @@ public class HttpWorkflowsMiddleware(RequestDelegate next, ITenantAccessor tenan
|
|||
var input = new Dictionary<string, object>
|
||||
{
|
||||
[HttpEndpoint.HttpContextInputKey] = true,
|
||||
[HttpEndpoint.RequestPathInputKey] = path
|
||||
[HttpEndpoint.RequestPathInputKey] = path.NormalizeRoute()
|
||||
};
|
||||
|
||||
var cancellationToken = httpContext.RequestAborted;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ public class RouteMatcher : IRouteMatcher
|
|||
public RouteValueDictionary? Match(string routeTemplate, string route)
|
||||
{
|
||||
var normalizedRoute = route.NormalizeRoute();
|
||||
var template = TemplateParser.Parse(routeTemplate);
|
||||
var normalizedRouteTemplate = routeTemplate.NormalizeRoute();
|
||||
var template = TemplateParser.Parse(normalizedRouteTemplate);
|
||||
var matcher = new TemplateMatcher(template, GetDefaults(template));
|
||||
var values = new RouteValueDictionary();
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
using Elsa.Workflows.ComponentTests.Abstractions;
|
||||
using Elsa.Workflows.ComponentTests.Fixtures;
|
||||
|
||||
namespace Elsa.Workflows.ComponentTests.Scenarios.HttpWorkflows;
|
||||
|
||||
public class RouteDataTests(App app) : AppComponentTest(app)
|
||||
{
|
||||
[Fact]
|
||||
public async Task RouteDataWorkflow_ShouldRespondWithRouteData()
|
||||
{
|
||||
var client = WorkflowServer.CreateHttpWorkflowClient();
|
||||
var response = await client.GetStringAsync("orders/42");
|
||||
Assert.Equal("42", response);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
using Elsa.Http;
|
||||
using Elsa.Workflows.Activities;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Elsa.Workflows.ComponentTests.Scenarios.HttpWorkflows.Workflows;
|
||||
|
||||
public class RouteDataWorkflow : WorkflowBase
|
||||
{
|
||||
protected override void Build(IWorkflowBuilder builder)
|
||||
{
|
||||
var routeDataVariable = builder.WithVariable<IDictionary<string, object>>();
|
||||
|
||||
builder.Root = new Sequence
|
||||
{
|
||||
Activities =
|
||||
[
|
||||
new HttpEndpoint
|
||||
{
|
||||
Path = new("orders/{id}"),
|
||||
SupportedMethods = new([HttpMethods.Get]),
|
||||
CanStartWorkflow = true,
|
||||
RouteData = new(routeDataVariable)
|
||||
},
|
||||
new WriteHttpResponse
|
||||
{
|
||||
Content = new(context => routeDataVariable.Get(context)!["id"].ToString()),
|
||||
ContentType = new("text/plain")
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue