Skip to content

Commit 50f05c7

Browse files
committed
fix: use null redactor if not injected
1 parent e73c351 commit 50f05c7

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/Cnblogs.Architecture.Ddd.Cqrs.ServiceAgent/Cnblogs.Architecture.Ddd.Cqrs.ServiceAgent.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
</ItemGroup>
3030

3131
<ItemGroup>
32+
<PackageReference Include="Microsoft.Extensions.Compliance.Redaction" Version="10.0.0" />
3233
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="10.0.0" />
3334
</ItemGroup>
3435
</Project>

src/Cnblogs.Architecture.Ddd.Cqrs.ServiceAgent/InjectExtensions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System.Net.Http.Headers;
22
using Cnblogs.Architecture.Ddd.Cqrs.AspNetCore;
3+
using Microsoft.Extensions.Compliance.Redaction;
34
using Microsoft.Extensions.DependencyInjection;
5+
using Microsoft.Extensions.DependencyInjection.Extensions;
46
using Microsoft.Extensions.Http.Logging;
57
using Microsoft.Extensions.Http.Resilience;
68

@@ -27,6 +29,7 @@ public static IHttpClientBuilder AddServiceAgent<TClient>(
2729
Action<HttpStandardResilienceOptions>? pollyConfigure = null)
2830
where TClient : class
2931
{
32+
services.TryAddSingleton<IRedactorProvider, NullRedactorProvider>();
3033
var builder = services.AddHttpClient<TClient>(h =>
3134
{
3235
h.BaseAddress = new Uri(baseUri);
@@ -55,6 +58,7 @@ public static IHttpClientBuilder AddServiceAgent<TClient, TImplementation>(
5558
where TClient : class
5659
where TImplementation : class, TClient
5760
{
61+
services.TryAddSingleton<IRedactorProvider, NullRedactorProvider>();
5862
var builder = services.AddHttpClient<TClient, TImplementation>(h =>
5963
{
6064
h.BaseAddress = new Uri(baseUri);

0 commit comments

Comments
 (0)