Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/SharedKernel/Extensions/HttpContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public static void MarkAsPrivateEndpoint(this HttpResponse response)
response.Headers.Append("X-Private-Endpoint", "1");
}

public static void MarkAsPrivateEndpoint(this IHttpContextAccessor contextAccessor)
{
contextAccessor.HttpContext?.Response.Headers.Append("X-Private-Endpoint", "1");
}

public static void MarkAsPrivateEndpoint(this HttpContextAccessor contextAccessor)
{
contextAccessor.HttpContext?.Response.Headers.Append("X-Private-Endpoint", "1");
Expand Down
6 changes: 4 additions & 2 deletions src/SharedKernel/Extensions/SignalRExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.DependencyInjection;
using ResponseCrafter.ExceptionHandlers.SignalR;
using StackExchange.Redis;

namespace SharedKernel.Extensions;
Expand All @@ -11,7 +13,7 @@ public static WebApplicationBuilder AddSignalR(this WebApplicationBuilder builde
{
builder
.Services
.AddSignalR()
.AddSignalR(o => o.AddFilter<SignalRExceptionFilter>())
.AddMessagePackProtocol();

return builder;
Expand All @@ -21,7 +23,7 @@ public static WebApplicationBuilder AddDistributedSignalR(this WebApplicationBui
{
builder
.Services
.AddSignalR()
.AddSignalR(o => o.AddFilter<SignalRExceptionFilter>())
.AddMessagePackProtocol()
.AddStackExchangeRedis(builder.Configuration.GetRedisUrl(),
options =>
Expand Down
4 changes: 2 additions & 2 deletions src/SharedKernel/Logging/RequestResponseLoggingMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal class RequestResponseLoggingMiddleware(RequestDelegate next, ILogger<Re

public async Task InvokeAsync(HttpContext context)
{
if (context.Request.Method.Equals("OPTIONS", StringComparison.OrdinalIgnoreCase))
if (HttpMethods.IsOptions(context.Request.Method))
{
await next(context);
return;
Expand All @@ -31,6 +31,7 @@ public async Task InvokeAsync(HttpContext context)
var originalBodyStream = context.Response.Body;
await using var responseBody = new MemoryStream();
context.Response.Body = responseBody;

var stopwatch = Stopwatch.GetTimestamp();
try
{
Expand Down Expand Up @@ -81,7 +82,6 @@ public async Task InvokeAsync(HttpContext context)
var body = await reader.ReadToEndAsync();
var sanitizedHeaders = JsonSerializer.Serialize(RedactSensitiveData(headers));
var bodyContent = JsonSerializer.Serialize(ParseAndRedactJson(body));

return (sanitizedHeaders, bodyContent);
}

Expand Down
8 changes: 4 additions & 4 deletions src/SharedKernel/SharedKernel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<Authors>Pandatech</Authors>
<Copyright>MIT</Copyright>
<Version>1.0.20</Version>
<Version>1.0.21</Version>
<PackageId>Pandatech.SharedKernel</PackageId>
<Title>Pandatech Shared Kernel Library</Title>
<PackageTags>Pandatech, shared kernel, library, OpenAPI, Swagger, utilities, scalar</PackageTags>
<Description>Pandatech.SharedKernel provides centralized configurations, utilities, and extensions for ASP.NET Core projects. For more information refere to readme.md document.</Description>
<RepositoryUrl>https://github.com/PandaTechAM/be-lib-sharedkernel</RepositoryUrl>
<PackageReleaseNotes>Nuget updates</PackageReleaseNotes>
<PackageReleaseNotes>Nuget updates and SignalR fix</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -51,8 +51,8 @@
<PackageReference Include="Pandatech.FluentMinimalApiMapper" Version="2.0.1" />
<PackageReference Include="Pandatech.PandaVaultClient" Version="4.0.3" />
<PackageReference Include="Pandatech.RegexBox" Version="3.0.0" />
<PackageReference Include="Pandatech.ResponseCrafter" Version="5.1.1" />
<PackageReference Include="Scalar.AspNetCore" Version="1.2.56" />
<PackageReference Include="Pandatech.ResponseCrafter" Version="5.1.2" />
<PackageReference Include="Scalar.AspNetCore" Version="1.2.61" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="7.2.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/SharedKernel.Tests/SharedKernel.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down