Skip to content

Commit 4f3ba09

Browse files
authored
feat: add Azure Functions middleware for HTTP correlation ID management (#562)
* feat: add Azure Functions middleware for HTTP correlation ID management * style: Reformatted solution
1 parent aa0f4ba commit 4f3ba09

41 files changed

Lines changed: 882 additions & 35 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.csharpierignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
**/nuget.config
2-
**/_snapshots/
3-
**/_snapshot/
1+
**/[Nn]u[Gg]et.config
2+
**/*.verified.*
3+
**/*.received.*

.editorconfig

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,22 @@ generated_code = true
4444
# XML project files
4545
[*.{slnx,csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,nativeproj,locproj}]
4646
indent_size = 2
47+
max_line_length = 200
4748

4849
# Xml build files
4950
[*.builds]
5051
indent_size = 2
52+
max_line_length = 200
5153

5254
# Xml files
5355
[*.{xml,stylecop,resx,ruleset}]
5456
indent_size = 2
57+
max_line_length = 200
5558

5659
# XML config files
5760
[*.{props,targets,ruleset,config,nuspec,vsixmanifest,vsct}]
5861
indent_size = 2
62+
max_line_length = 200
5963

6064
# JSON files
6165
[*.json]
@@ -86,10 +90,6 @@ insert_final_newline = false
8690
[*.sln]
8791
indent_style = tab
8892

89-
[*.{received,verified}.txt]
90-
insert_final_newline = false
91-
trim_trailing_whitespace = false
92-
9393
[*.{cs,csx,vb,vbx}]
9494
# .NET Code Style Settings
9595
# See https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
@@ -266,19 +266,18 @@ dotnet_diagnostic.IDE0290.severity = sugges
266266
# [CSharpier] Incompatible rules deactivated
267267
# https://csharpier.com/docs/IntegratingWithLinters#code-analysis-rules
268268
dotnet_diagnostic.IDE0055.severity = none
269-
dotnet_diagnostic.SA1000.severity = none
270-
dotnet_diagnostic.SA1009.severity = none
271-
dotnet_diagnostic.SA1111.severity = none
272-
dotnet_diagnostic.SA1118.severity = none
273-
dotnet_diagnostic.SA1137.severity = none
274-
dotnet_diagnostic.SA1413.severity = none
275-
dotnet_diagnostic.SA1500.severity = none
276-
dotnet_diagnostic.SA1501.severity = none
277-
dotnet_diagnostic.SA1502.severity = none
278-
dotnet_diagnostic.SA1504.severity = none
279-
dotnet_diagnostic.SA1515.severity = none
280-
dotnet_diagnostic.SA1516.severity = none
281269

282270
# Support for NetEvolve.Arguments Methods
283271
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1062#null-check-validation-methods
284272
dotnet_code_quality.CA1062.null_check_validation_methods = M:NetEvolve.Arguments.Argument.ThrowIfNull(System.Object,System.String)|M:NetEvolve.Arguments.Argument.ThrowIfNull(System.Void*,System.String)|M:NetEvolve.Arguments.Argument.ThrowIfNullOrEmpty(System.String,System.String)|M:NetEvolve.Arguments.Argument.ThrowIfNullOrEmpty``1(System.Collections.Generic.IEnumerable{``0},System.String)|M:NetEvolve.Arguments.Argument.ThrowIfNullOrWhiteSpace(System.String,System.String)
273+
274+
# Disable all style rules for generated code
275+
[*.{received,verified}.*]
276+
generated_code = true
277+
# Disable all style rules for migrations
278+
dotnet_analyzer_diagnostic.severity = none
279+
280+
[**/Migrations/*.{cs,csx,vb,vbx}]
281+
generated_code = true
282+
# Disable all style rules for migrations
283+
dotnet_analyzer_diagnostic.severity = none

Directory.Build.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@
1313
<RepositoryUrl>https://github.com/dailydevops/http.correlation.git</RepositoryUrl>
1414
<PackageReleaseNotes>$(PackageProjectUrl)/releases</PackageReleaseNotes>
1515
<PackageTags>http;tracking;correlation;request id;</PackageTags>
16-
<RootNamespace>NetEvolve.Http.Correlation</RootNamespace>
1716
</PropertyGroup>
1817
</Project>

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<GlobalPackageReference Include="SonarAnalyzer.CSharp" Version="10.21.0.135717" />
1414
</ItemGroup>
1515
<ItemGroup>
16+
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Core" Version="2.51.0" />
1617
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.5" />
1718
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.5" />
1819
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.5.2" />

Http.Correlation.slnx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
<File Path="Directory.Solution.props" />
1111
<File Path="GitVersion.yml" />
1212
<File Path="LICENSE" />
13-
<File Path="new-project.ps1" />
1413
<File Path="nuget.config" />
1514
<File Path="README.md" />
16-
<File Path="update-solution.ps1" />
1715
</Folder>
1816
<Folder Name="/src/">
1917
<Project Path="src/NetEvolve.Http.Correlation.Abstractions/NetEvolve.Http.Correlation.Abstractions.csproj" />
2018
<Project Path="src/NetEvolve.Http.Correlation.AspNetCore/NetEvolve.Http.Correlation.AspNetCore.csproj" />
19+
<Project Path="src/NetEvolve.Http.Correlation.Azure.Functions/NetEvolve.Http.Correlation.Azure.Functions.csproj" Id="639963ff-323b-4f12-804e-c1b97a2f1cf2" />
2120
<Project Path="src/NetEvolve.Http.Correlation.HttpClient/NetEvolve.Http.Correlation.HttpClient.csproj" />
2221
<Project Path="src/NetEvolve.Http.Correlation.TestGenerator/NetEvolve.Http.Correlation.TestGenerator.csproj" />
2322
<Project Path="src/NetEvolve.Http.Correlation.Ulid/NetEvolve.Http.Correlation.Ulid.csproj" />
@@ -26,6 +25,8 @@
2625
<Project Path="tests/NetEvolve.Http.Correlation.Abstractions.Tests.Unit/NetEvolve.Http.Correlation.Abstractions.Tests.Unit.csproj" />
2726
<Project Path="tests/NetEvolve.Http.Correlation.AspNetCore.Tests.Integration/NetEvolve.Http.Correlation.AspNetCore.Tests.Integration.csproj" />
2827
<Project Path="tests/NetEvolve.Http.Correlation.AspNetCore.Tests.Unit/NetEvolve.Http.Correlation.AspNetCore.Tests.Unit.csproj" />
28+
<Project Path="tests/NetEvolve.Http.Correlation.Azure.Functions.Tests.Integration/NetEvolve.Http.Correlation.Azure.Functions.Tests.Integration.csproj" />
29+
<Project Path="tests/NetEvolve.Http.Correlation.Azure.Functions.Tests.Unit/NetEvolve.Http.Correlation.Azure.Functions.Tests.Unit.csproj" />
2930
<Project Path="tests/NetEvolve.Http.Correlation.HttpClient.Tests.Unit/NetEvolve.Http.Correlation.HttpClient.Tests.Unit.csproj" />
3031
<Project Path="tests/NetEvolve.Http.Correlation.TestGenerator.Tests.Unit/NetEvolve.Http.Correlation.TestGenerator.Tests.Unit.csproj" />
3132
<Project Path="tests/NetEvolve.Http.Correlation.Ulid.Tests.Unit/NetEvolve.Http.Correlation.Ulid.Tests.Unit.csproj" />

src/NetEvolve.Http.Correlation.Abstractions/Abstractions/IHttpCorrelationAccessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public interface IHttpCorrelationAccessor
1010
/// <summary>
1111
/// Gets the current Correlation Id from the <see cref="HttpContext"/>.
1212
/// </summary>
13-
string CorrelationId { get; }
13+
string CorrelationId { get; internal set; }
1414

1515
/// <summary>
1616
/// Gets the header name, which is used.

src/NetEvolve.Http.Correlation.AspNetCore/HttpCorrelationBuilder.cs renamed to src/NetEvolve.Http.Correlation.Abstractions/HttpCorrelationBuilder.cs

File renamed without changes.

src/NetEvolve.Http.Correlation.AspNetCore/HttpCorrelationBuilderExtensions.cs renamed to src/NetEvolve.Http.Correlation.Abstractions/HttpCorrelationBuilderExtensions.cs

File renamed without changes.

src/NetEvolve.Http.Correlation.Abstractions/NetEvolve.Http.Correlation.Abstractions.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFrameworks>$(_TargetFrameworks)</TargetFrameworks>
4+
<RootNamespace>NetEvolve.Http.Correlation</RootNamespace>
45
</PropertyGroup>
56
<PropertyGroup>
67
<Description>Abstractions for the uniform use of Http.Correlation. Based on the primary Http header `X-Correlation-ID` as well as the alternative Http header `X-Request-ID`.</Description>
@@ -9,6 +10,10 @@
910
<ItemGroup>
1011
<InternalsVisibleTo Include="NetEvolve.Http.Correlation.AspNetCore" />
1112
<InternalsVisibleTo Include="NetEvolve.Http.Correlation.AspNetCore.Tests.Integration" />
13+
<InternalsVisibleTo Include="NetEvolve.Http.Correlation.AspNetCore.Tests.Unit" />
14+
<InternalsVisibleTo Include="NetEvolve.Http.Correlation.Azure.Functions" />
15+
<InternalsVisibleTo Include="NetEvolve.Http.Correlation.Azure.Functions.Tests.Integration" />
16+
<InternalsVisibleTo Include="NetEvolve.Http.Correlation.Azure.Functions.Tests.Unit" />
1217
<InternalsVisibleTo Include="NetEvolve.Http.Correlation.HttpClient" />
1318
<InternalsVisibleTo Include="NetEvolve.Http.Correlation.HttpClient.Tests.Unit" />
1419
<InternalsVisibleTo Include="NetEvolve.Http.Correlation.TestGenerator" />

src/NetEvolve.Http.Correlation.AspNetCore/ApplicationBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace NetEvolve.Http.Correlation;
1+
namespace NetEvolve.Http.Correlation.AspNetCore;
22

33
using System;
44
using Microsoft.AspNetCore.Builder;

0 commit comments

Comments
 (0)