1 Star 0 Fork 149

hangshan-boop/FastGithub

forked from Xingyuan55/FastGithub 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ServiceCollectionExtensions.cs 1.58 KB
一键复制 编辑 原始数据 按行查看 历史
Xingyuan55 提交于 2022-11-16 08:01 . start
using FastGithub.HttpServer.Certs;
using FastGithub.HttpServer.Certs.CaCertInstallers;
using FastGithub.HttpServer.HttpMiddlewares;
using FastGithub.HttpServer.TcpMiddlewares;
using FastGithub.HttpServer.TlsMiddlewares;
using Microsoft.Extensions.DependencyInjection;
namespace FastGithub
{
/// <summary>
/// http反向代理的服务注册扩展
/// </summary>
public static class ServiceCollectionExtensions
{
/// <summary>
/// 添加http反向代理
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
public static IServiceCollection AddReverseProxy(this IServiceCollection services)
{
return services
.AddMemoryCache()
.AddHttpForwarder()
.AddSingleton<CertService>()
.AddSingleton<ICaCertInstaller, CaCertInstallerOfMacOS>()
.AddSingleton<ICaCertInstaller, CaCertInstallerOfWindows>()
.AddSingleton<ICaCertInstaller, CaCertInstallerOfLinuxRedHat>()
.AddSingleton<ICaCertInstaller, CaCertInstallerOfLinuxDebian>()
// tcp
.AddSingleton<HttpProxyMiddleware>()
.AddSingleton<TunnelMiddleware>()
// tls
.AddSingleton<TlsInvadeMiddleware>()
.AddSingleton<TlsRestoreMiddleware>()
// http
.AddSingleton<HttpProxyPacMiddleware>()
.AddSingleton<RequestLoggingMiddleware>()
.AddSingleton<HttpReverseProxyMiddleware>();
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/hangshan-boop/FastGithub.git
git@gitee.com:hangshan-boop/FastGithub.git
hangshan-boop
FastGithub
FastGithub
master

搜索帮助