Skip to content

Commit

Permalink
fix urlPath
Browse files Browse the repository at this point in the history
  • Loading branch information
dawkaka committed Apr 14, 2024
1 parent c4ca0fc commit 9224d55
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ApiToolKit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,24 @@ public async Task InvokeAsync(HttpContext context)
var pathParams = context.GetRouteData().Values
.Where(v => !string.IsNullOrEmpty(v.Value?.ToString()))
.ToDictionary(v => v.Key, v => v.Value.ToString());
var urlPath = "";
var endpoint = context.GetEndpoint();
if (endpoint != null)
{
var routePattern = (endpoint as Microsoft.AspNetCore.Routing.RouteEndpoint)?.RoutePattern?.RawText;

if (routePattern != null)
{
urlPath = routePattern;
}
}


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

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

await _client.PublishMessageAsync(payload);
}
Expand Down
25 changes: 25 additions & 0 deletions apitoolkit-dotnet.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "apitoolkit-dotnet", "apitoolkit-dotnet.csproj", "{F869FF96-3574-44A6-9ABE-2261D0119CDE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F869FF96-3574-44A6-9ABE-2261D0119CDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F869FF96-3574-44A6-9ABE-2261D0119CDE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F869FF96-3574-44A6-9ABE-2261D0119CDE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F869FF96-3574-44A6-9ABE-2261D0119CDE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {80A94D82-2355-4EB5-93B9-5DB94457E1F9}
EndGlobalSection
EndGlobal

0 comments on commit 9224d55

Please sign in to comment.