From e3c3a3285331bfedb1a6b50b1e0ae7485ecf9eb5 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Thu, 15 Jul 2021 15:33:31 +0200 Subject: [PATCH] Hotfix for HttpEndpointMiddleware Fixes that subpath no longer matched any workflows --- appveyor.yml | 2 +- .../Middleware/HttpEndpointMiddleware.cs | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 6799045d5..a000d2f5c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,7 +11,7 @@ environment: sonarcloud_api_key: secure: qaE9kOVkGGFM7ZMf3YeliZxDU9udTCy6W5xXHJ9T+tXv5qXPMYlIdR7hyNgxW04A -version: 2.2.0-preview.{build} +version: 2.1.1.{build} init: - cmd: git config --global core.autocrlf true diff --git a/src/activities/Elsa.Activities.Http/Middleware/HttpEndpointMiddleware.cs b/src/activities/Elsa.Activities.Http/Middleware/HttpEndpointMiddleware.cs index 7a2272e28..f68cd5558 100644 --- a/src/activities/Elsa.Activities.Http/Middleware/HttpEndpointMiddleware.cs +++ b/src/activities/Elsa.Activities.Http/Middleware/HttpEndpointMiddleware.cs @@ -40,19 +40,26 @@ namespace Elsa.Activities.Http.Middleware var basePath = options.Value.BasePath; var request = httpContext.Request; + string path; + // If a base path was configured, try to match against that first. if (basePath != null) { // If no match, continue with the next middleware in the pipeline. - if (!request.Path.StartsWithSegments(basePath.Value)) + if (!request.Path.StartsWithSegments(basePath.Value, out _, out var remainingPath)) { await _next(httpContext); return; } + + path = remainingPath.Value.ToLowerInvariant(); + } + else + { + path = httpContext.Request.Path.Value.ToLowerInvariant(); } var cancellationToken = CancellationToken.None; // Prevent half-way request abortion (which also happens when WriteHttpResponse writes to the response). - var path = httpContext.Request.Path.Value.ToLowerInvariant(); var method = httpContext.Request.Method!.ToLowerInvariant(); request.TryGetCorrelationId(out var correlationId);