diff --git a/ApiToolKit.cs b/ApiToolKit.cs index 2688ca3..29c984e 100644 --- a/ApiToolKit.cs +++ b/ApiToolKit.cs @@ -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); } diff --git a/apitoolkit-dotnet.sln b/apitoolkit-dotnet.sln new file mode 100644 index 0000000..55ec011 --- /dev/null +++ b/apitoolkit-dotnet.sln @@ -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