50 lines
1.9 KiB
C#
50 lines
1.9 KiB
C#
using Kurisu.AspNetCore.Startup;
|
|
|
|
namespace Dlhis.Basic.Common.Packs;
|
|
|
|
public class MessagePack : BaseAppPack
|
|
{
|
|
public override void ConfigureServices(IServiceCollection services)
|
|
{
|
|
services.AddHttpClient("jinko.oa", (_, _) => { })
|
|
.ConfigurePrimaryHttpMessageHandler(() =>
|
|
{
|
|
var handler = new HttpClientHandler
|
|
{
|
|
ClientCertificateOptions = ClientCertificateOption.Manual,
|
|
ServerCertificateCustomValidationCallback = (_, _, _, _) => true
|
|
};
|
|
|
|
return handler;
|
|
});
|
|
|
|
services.AddHttpClient("jinko.httpclient", (sp, httpClient) =>
|
|
{
|
|
// "BaseUrl": "https://oapi.dingtalk.com",
|
|
// "AgentId": "2768073678",
|
|
// "AppId": "dingumelppews6rah7x9",
|
|
// "AppSecret": "nsWfJTVjYesHVzrLiP-t1TQqMQvC1L_kZNfXfnIyzcXK4pCTfKprkjZcxAbsDR_l",
|
|
|
|
httpClient.BaseAddress = new Uri("https://oapi.dingtalk.com");
|
|
httpClient.Timeout = TimeSpan.FromSeconds(30);
|
|
})
|
|
// .SetHandlerLifetime(TimeSpan.FromMinutes(5))
|
|
// .addd((res) =>
|
|
// {
|
|
// return HttpPolicyExtensions
|
|
// .HandleTransientHttpError()
|
|
// .OrResult(msg => msg.StatusCode != HttpStatusCode.OK)
|
|
// .WaitAndRetryAsync(6, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));
|
|
// })
|
|
.ConfigurePrimaryHttpMessageHandler(() =>
|
|
{
|
|
var handler = new HttpClientHandler
|
|
{
|
|
ClientCertificateOptions = ClientCertificateOption.Manual,
|
|
ServerCertificateCustomValidationCallback = (_, _, _, _) => true
|
|
};
|
|
|
|
return handler;
|
|
});
|
|
}
|
|
} |