Skip to content

Commit 9224d55

Browse files
committed
fix urlPath
1 parent c4ca0fc commit 9224d55

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

ApiToolKit.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,24 @@ public async Task InvokeAsync(HttpContext context)
5353
var pathParams = context.GetRouteData().Values
5454
.Where(v => !string.IsNullOrEmpty(v.Value?.ToString()))
5555
.ToDictionary(v => v.Key, v => v.Value.ToString());
56+
var urlPath = "";
57+
var endpoint = context.GetEndpoint();
58+
if (endpoint != null)
59+
{
60+
var routePattern = (endpoint as Microsoft.AspNetCore.Routing.RouteEndpoint)?.RoutePattern?.RawText;
61+
62+
if (routePattern != null)
63+
{
64+
urlPath = routePattern;
65+
}
66+
}
67+
5668

5769
var responseHeaders = context.Response.Headers.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.ToList());
5870

5971
var payload = _client.BuildPayload("DotNet", stopwatch, context.Request, context.Response.StatusCode,
6072
System.Text.Encoding.UTF8.GetBytes(requestBody), System.Text.Encoding.UTF8.GetBytes(responseBody),
61-
responseHeaders, pathParams, context.Request.Path);
73+
responseHeaders, pathParams, urlPath);
6274

6375
await _client.PublishMessageAsync(payload);
6476
}

apitoolkit-dotnet.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.002.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "apitoolkit-dotnet", "apitoolkit-dotnet.csproj", "{F869FF96-3574-44A6-9ABE-2261D0119CDE}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{F869FF96-3574-44A6-9ABE-2261D0119CDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{F869FF96-3574-44A6-9ABE-2261D0119CDE}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{F869FF96-3574-44A6-9ABE-2261D0119CDE}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{F869FF96-3574-44A6-9ABE-2261D0119CDE}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {80A94D82-2355-4EB5-93B9-5DB94457E1F9}
24+
EndGlobalSection
25+
EndGlobal

0 commit comments

Comments
 (0)