Browse Source
Merge pull request #412 from colinin/4.4.2
feat(dapr): 使dapr代理请求过程可配置
pull/426/head
yx lin
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
51 additions and
37 deletions
-
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/AbpDaprClientProxyOptions.cs
-
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/DynamicProxying/DynamicDaprClientProxyInterceptor.cs
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Net.Http; |
|
|
|
|
|
|
|
namespace LINGYUN.Abp.Dapr.Client.DynamicProxying |
|
|
|
{ |
|
|
|
@ -7,9 +8,17 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying |
|
|
|
{ |
|
|
|
public Dictionary<Type, DynamicDaprClientProxyConfig> DaprClientProxies { get; set; } |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 增加一个可配置的请求消息
|
|
|
|
/// 参数一: appId
|
|
|
|
/// 参数二: HttpRequestMessage
|
|
|
|
/// </summary>
|
|
|
|
public List<Action<string, HttpRequestMessage>> ProxyRequestActions { get; } |
|
|
|
|
|
|
|
public AbpDaprClientProxyOptions() |
|
|
|
{ |
|
|
|
DaprClientProxies = new Dictionary<Type, DynamicDaprClientProxyConfig>(); |
|
|
|
ProxyRequestActions = new List<Action<string, HttpRequestMessage>>(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -212,6 +212,11 @@ namespace LINGYUN.Abp.Dapr.Client.DynamicProxying |
|
|
|
{ |
|
|
|
requestMessage.Headers.Authorization = httpClient.DefaultRequestHeaders.Authorization; |
|
|
|
} |
|
|
|
// 增加一个可配置的请求消息
|
|
|
|
foreach (var clientRequestAction in ClientProxyOptions.ProxyRequestActions) |
|
|
|
{ |
|
|
|
clientRequestAction(remoteServiceConfig.AppId, requestMessage); |
|
|
|
} |
|
|
|
|
|
|
|
var response = await daprClient.InvokeMethodWithResponseAsync(requestMessage, GetCancellationToken()); |
|
|
|
|
|
|
|
|