47 lines
1.7 KiB
C#
47 lines
1.7 KiB
C#
using System.Security.Authentication;
|
|
using Fake.AspNetCore;
|
|
using Fake.EventBus.RabbitMQ;
|
|
using Fake.Modularity;
|
|
using Fake.ObjectMapping.AutoMapper;
|
|
using InterfaceForward.Application.Contracts;
|
|
using InterfaceForward.Repositories;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace InterfaceForward.Application;
|
|
|
|
[DependsOn(typeof(FakeAspNetCoreModule))]
|
|
[DependsOn(typeof(FakeObjectMappingAutoMapperModule))]
|
|
[DependsOn(typeof(FakeEventBusRabbitMqModule))]
|
|
[DependsOn(typeof(InterfaceForwardRepositoriesModule))]
|
|
public class InterfaceForwardApplicationModule:FakeModule
|
|
{
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
var configuration = context.Services.GetConfiguration();
|
|
|
|
context.Services.Configure<FakeAutoMapperOptions>(options =>
|
|
{
|
|
options.AddMaps<InterfaceForwardApplicationModule>();
|
|
});
|
|
|
|
context.Services.Configure<InterfaceRelayOptions>(configuration.GetSection("InterfaceRelay"));
|
|
|
|
// 预热
|
|
NatashaInitializer.Preheating();
|
|
|
|
context.Services.AddHttpClient("forward", client =>
|
|
{
|
|
client.Timeout = TimeSpan.FromSeconds(20);
|
|
})
|
|
.ConfigurePrimaryHttpMessageHandler(_ =>
|
|
{
|
|
var httpClientHandler = new HttpClientHandler();
|
|
// 确保支持较新的 SSL/TLS 版本
|
|
httpClientHandler.SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13;
|
|
// 忽略 SSL/TLS 证书错误
|
|
httpClientHandler.ServerCertificateCustomValidationCallback =
|
|
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
|
|
return httpClientHandler;
|
|
});
|
|
}
|
|
} |