Skip to content

Commit d7af0e0

Browse files
authored
nist webhook dump and related bodies update (#127)
1 parent cd3914d commit d7af0e0

26 files changed

+317
-121
lines changed

.github/workflows/nuget-bodies.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Publish Nist.Bodies
22
on:
33
push:
44
paths:
5-
- 'dotnet/bodies/lib/**'
5+
- 'bodies/lib/**'
66
- '.github/workflows/nuget-bodies.yaml'
77
workflow_dispatch:
88

@@ -13,5 +13,5 @@ jobs:
1313
steps:
1414
- uses: astorDev/versy/calver/nuget@main
1515
with:
16-
project: dotnet/bodies/lib/Nist.Bodies
16+
project: bodies/lib/Nist.Bodies
1717
nuget-api-key: ${{ secrets.NUGET_API_KEY }}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Nist.Webhooks.Dump Nuget
2+
on:
3+
push:
4+
paths:
5+
- 'webhooks/accept/lib/**'
6+
- '.github/workflows/nuget-webhooks-dump.yaml'
7+
workflow_dispatch:
8+
9+
jobs:
10+
publish:
11+
name: Pack & Publish nuget
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: astorDev/versy/calver/nuget@main
15+
with:
16+
project: webhooks/accept/lib/Nist.Webhooks.Dump
17+
nuget-api-key: ${{ secrets.NUGET_API_KEY }}

Nist.sln

+38
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "io", "io", "{45D49346-A1EC-
3333
EndProject
3434
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nist.Logs", "logging\dotnet\io\lib\Nist.Logs.csproj", "{0336C795-38E1-4278-BBFF-EA9205DCEE10}"
3535
EndProject
36+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "webhooks", "webhooks", "{80986F3E-256A-4186-B2FC-44F932FAEDEE}"
37+
EndProject
38+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "accept", "accept", "{BBAE48E8-3CAF-4E58-95D4-1B8D8C6202CB}"
39+
EndProject
40+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nist.Webhooks.Dump", "webhooks\accept\lib\Nist.Webhooks.Dump.csproj", "{CBDE7E9E-76BB-4A64-940C-3D2F06782A09}"
41+
EndProject
42+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "send", "send", "{9F87D931-2A57-4C0E-9E28-22EE758171D0}"
43+
EndProject
44+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nist.Webhooks.Sender", "webhooks\send\lib\Nist.Webhooks.Sender.csproj", "{DEF76DCF-DE6C-4E87-B247-D6841F75B8F0}"
45+
EndProject
46+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nist.Webhooks.Playground", "webhooks\playground\Nist.Webhooks.Playground.csproj", "{21D90A7E-21E1-4A8C-B211-9AF0DFFAB1AC}"
47+
EndProject
48+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bodies", "bodies", "{FAAF0C92-65CB-4284-AAF0-3ACD40E42C0E}"
49+
EndProject
50+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nist.Bodies", "bodies\lib\Nist.Bodies.csproj", "{A294EA1A-2CAE-4006-B317-755A6DF60E47}"
51+
EndProject
3652
Global
3753
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3854
Debug|Any CPU = Debug|Any CPU
@@ -74,6 +90,22 @@ Global
7490
{0336C795-38E1-4278-BBFF-EA9205DCEE10}.Debug|Any CPU.Build.0 = Debug|Any CPU
7591
{0336C795-38E1-4278-BBFF-EA9205DCEE10}.Release|Any CPU.ActiveCfg = Release|Any CPU
7692
{0336C795-38E1-4278-BBFF-EA9205DCEE10}.Release|Any CPU.Build.0 = Release|Any CPU
93+
{CBDE7E9E-76BB-4A64-940C-3D2F06782A09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
94+
{CBDE7E9E-76BB-4A64-940C-3D2F06782A09}.Debug|Any CPU.Build.0 = Debug|Any CPU
95+
{CBDE7E9E-76BB-4A64-940C-3D2F06782A09}.Release|Any CPU.ActiveCfg = Release|Any CPU
96+
{CBDE7E9E-76BB-4A64-940C-3D2F06782A09}.Release|Any CPU.Build.0 = Release|Any CPU
97+
{DEF76DCF-DE6C-4E87-B247-D6841F75B8F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
98+
{DEF76DCF-DE6C-4E87-B247-D6841F75B8F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
99+
{DEF76DCF-DE6C-4E87-B247-D6841F75B8F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
100+
{DEF76DCF-DE6C-4E87-B247-D6841F75B8F0}.Release|Any CPU.Build.0 = Release|Any CPU
101+
{21D90A7E-21E1-4A8C-B211-9AF0DFFAB1AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
102+
{21D90A7E-21E1-4A8C-B211-9AF0DFFAB1AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
103+
{21D90A7E-21E1-4A8C-B211-9AF0DFFAB1AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
104+
{21D90A7E-21E1-4A8C-B211-9AF0DFFAB1AC}.Release|Any CPU.Build.0 = Release|Any CPU
105+
{A294EA1A-2CAE-4006-B317-755A6DF60E47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
106+
{A294EA1A-2CAE-4006-B317-755A6DF60E47}.Debug|Any CPU.Build.0 = Debug|Any CPU
107+
{A294EA1A-2CAE-4006-B317-755A6DF60E47}.Release|Any CPU.ActiveCfg = Release|Any CPU
108+
{A294EA1A-2CAE-4006-B317-755A6DF60E47}.Release|Any CPU.Build.0 = Release|Any CPU
77109
EndGlobalSection
78110
GlobalSection(NestedProjects) = preSolution
79111
{3448B6A0-78B9-4F52-A971-9407F9B331CF} = {AA026DC3-ACA9-418C-9D5F-C0FA54F764CA}
@@ -87,5 +119,11 @@ Global
87119
{7F5FA821-5181-47B3-B7EF-A2D848813726} = {51CCC18E-8103-4031-A31C-EE3097946B4A}
88120
{45D49346-A1EC-4C9B-AC1B-0A2735A40B99} = {7F5FA821-5181-47B3-B7EF-A2D848813726}
89121
{0336C795-38E1-4278-BBFF-EA9205DCEE10} = {45D49346-A1EC-4C9B-AC1B-0A2735A40B99}
122+
{BBAE48E8-3CAF-4E58-95D4-1B8D8C6202CB} = {80986F3E-256A-4186-B2FC-44F932FAEDEE}
123+
{CBDE7E9E-76BB-4A64-940C-3D2F06782A09} = {BBAE48E8-3CAF-4E58-95D4-1B8D8C6202CB}
124+
{9F87D931-2A57-4C0E-9E28-22EE758171D0} = {80986F3E-256A-4186-B2FC-44F932FAEDEE}
125+
{DEF76DCF-DE6C-4E87-B247-D6841F75B8F0} = {9F87D931-2A57-4C0E-9E28-22EE758171D0}
126+
{21D90A7E-21E1-4A8C-B211-9AF0DFFAB1AC} = {80986F3E-256A-4186-B2FC-44F932FAEDEE}
127+
{A294EA1A-2CAE-4006-B317-755A6DF60E47} = {FAAF0C92-65CB-4284-AAF0-3ACD40E42C0E}
90128
EndGlobalSection
91129
EndGlobal
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
namespace Nist;
2+
3+
public enum DuplicateRegistrationBehavior
4+
{
5+
Throw,
6+
Ignore
7+
}
8+
9+
public static class DuplicateRegistrationDecorator
10+
{
11+
private readonly static HashSet<string> registered = [];
12+
13+
public static void HandleRegistration(
14+
this IApplicationBuilder app,
15+
string key,
16+
Action<IApplicationBuilder> registration,
17+
DuplicateRegistrationBehavior behavior = DuplicateRegistrationBehavior.Ignore
18+
)
19+
{
20+
if (registered.Contains(key))
21+
{
22+
if (behavior == DuplicateRegistrationBehavior.Throw)
23+
throw new InvalidOperationException($"{key} has already been registered.");
24+
25+
return;
26+
}
27+
28+
registration(app);
29+
registered.Add(key);
30+
}
31+
}

dotnet/bodies/lib/Nist.Bodies.csproj renamed to bodies/lib/Nist.Bodies.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1010
<PackageReadmeFile>README.md</PackageReadmeFile>
1111
<LangVersion>12.0</LangVersion>
12+
<RootNamespace>Nist</RootNamespace>
1213
</PropertyGroup>
1314

1415
<ItemGroup>
File renamed without changes.

dotnet/bodies/lib/RequestBodyStringReader.cs renamed to bodies/lib/RequestBodyStringReader.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Nist.Bodies;
1+
namespace Nist;
22

33
public class RequestBodyStringReader(RequestDelegate next)
44
{
@@ -21,9 +21,14 @@ public async Task Invoke(HttpContext context)
2121

2222
public static class RequestBodyStringReaderRegistration
2323
{
24-
public static void UseRequestBodyStringReader(this IApplicationBuilder app)
24+
public static void UseRequestBodyStringReader(this IApplicationBuilder app, DuplicateRegistrationBehavior duplicatingRegistrationBehavior = DuplicateRegistrationBehavior.Ignore)
2525
{
26-
app.UseMiddleware<RequestBodyStringReader>();
26+
DuplicateRegistrationDecorator.HandleRegistration(
27+
app,
28+
nameof(RequestBodyStringReader),
29+
(x) => x.UseMiddleware<RequestBodyStringReader>(),
30+
duplicatingRegistrationBehavior
31+
);
2732
}
2833
}
2934

dotnet/bodies/lib/ResponseBodyStringReader.cs renamed to bodies/lib/ResponseBodyStringReader.cs

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Nist.Bodies;
1+
namespace Nist;
22

33
public class ResponseBodyStringReader(RequestDelegate next)
44
{
@@ -25,9 +25,16 @@ public async Task Invoke(HttpContext context)
2525

2626
public static class ResponseBodyStringReaderRegistration
2727
{
28-
public static void UseResponseBodyStringReader(this IApplicationBuilder app)
28+
public static bool registered = false;
29+
30+
public static void UseResponseBodyStringReader(this IApplicationBuilder app, DuplicateRegistrationBehavior duplicatingRegistrationBehavior = DuplicateRegistrationBehavior.Ignore)
2931
{
30-
app.UseMiddleware<ResponseBodyStringReader>();
32+
DuplicateRegistrationDecorator.HandleRegistration(
33+
app,
34+
nameof(ResponseBodyStringReader),
35+
(x) => x.UseMiddleware<ResponseBodyStringReader>(),
36+
duplicatingRegistrationBehavior
37+
);
3138
}
3239
}
3340

dotnet/bodies/playground/action-filter/.http

-14
This file was deleted.

dotnet/bodies/playground/action-filter/PartyController.cs

-33
This file was deleted.

dotnet/bodies/playground/action-filter/Program.cs

-32
This file was deleted.

dotnet/bodies/playground/action-filter/Properties/launchSettings.json

-9
This file was deleted.

dotnet/bodies/playground/action-filter/action-filter.csproj

-15
This file was deleted.

dotnet/bodies/playground/action-filter/appsettings.json

-10
This file was deleted.

versions/0.5/index.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
- [ ] Nist.Template <VERSION>
2+
- [ ] Utilize RootNamespace
3+
- [ ] Nist.Webhooks.Sender <VERSION>
4+
- [ ] Nist.Webhooks.Dump <VERSION>
5+
- [ ] Nist.Bodies <VERSION>
6+
- [ ] `Nist` namespace
7+
- [ ] Idempotent Registration
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<RootNamespace>Nist</RootNamespace>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.3" />
12+
<PackageReference Include="Nist.Bodies" Version="2024.106.106.11" />
13+
</ItemGroup>
14+
15+
</Project>

0 commit comments

Comments
 (0)