Skip to content

Commit f64ba04

Browse files
committed
refact: extract property body constant
1 parent 3937bde commit f64ba04

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/Voxel.MiddyNet.HttpJsonBodyParserMiddleware/HttpJsonBodyParserMiddleware.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ namespace Voxel.MiddyNet.HttpJsonBodyParserMiddleware
88
{
99
public class HttpJsonBodyParserMiddleware<T> : ILambdaMiddleware<APIGatewayProxyRequest, APIGatewayProxyResponse>
1010
{
11+
private const string BodyContextKey = "Body";
12+
1113
public Task Before(APIGatewayProxyRequest lambdaEvent, MiddyNetContext context)
1214
{
1315
if (!HasJsonContentHeaders(lambdaEvent))
1416
{
15-
context.AdditionalContext.Add("Body", lambdaEvent.Body);
17+
context.AdditionalContext.Add(BodyContextKey, lambdaEvent.Body);
1618
return Task.CompletedTask;
1719
}
1820

@@ -24,7 +26,7 @@ public Task Before(APIGatewayProxyRequest lambdaEvent, MiddyNetContext context)
2426
var source = JsonSerializer.Deserialize<T>(lambdaEvent.Body);
2527

2628

27-
context.AdditionalContext.Add("Body", source);
29+
context.AdditionalContext.Add(BodyContextKey, source);
2830
return Task.CompletedTask;
2931
}
3032

src/Voxel.MiddyNet.HttpJsonBodyParserMiddleware/HttpV2JsonBodyParserMiddleware.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ namespace Voxel.MiddyNet.HttpJsonBodyParserMiddleware
88
{
99
public class HttpV2JsonBodyParserMiddleware<T> : ILambdaMiddleware<APIGatewayHttpApiV2ProxyRequest, APIGatewayHttpApiV2ProxyResponse>
1010
{
11+
private const string BodyContextKey = "Body";
12+
1113
public Task Before(APIGatewayHttpApiV2ProxyRequest lambdaEvent, MiddyNetContext context)
1214
{
1315
if (!HasJsonContentHeaders(lambdaEvent))
1416
{
15-
context.AdditionalContext.Add("Body", lambdaEvent.Body);
17+
context.AdditionalContext.Add(BodyContextKey, lambdaEvent.Body);
1618
return Task.CompletedTask;
1719
}
1820

@@ -24,7 +26,7 @@ public Task Before(APIGatewayHttpApiV2ProxyRequest lambdaEvent, MiddyNetContext
2426
var source = JsonSerializer.Deserialize<T>(lambdaEvent.Body);
2527

2628

27-
context.AdditionalContext.Add("Body", source);
29+
context.AdditionalContext.Add(BodyContextKey, source);
2830
return Task.CompletedTask;
2931
}
3032

0 commit comments

Comments
 (0)