diff --git a/FastGithub.ReverseProxy/ReverseProxyApplicationBuilderExtensions.cs b/FastGithub.ReverseProxy/ReverseProxyApplicationBuilderExtensions.cs index d785172..79f6996 100644 --- a/FastGithub.ReverseProxy/ReverseProxyApplicationBuilderExtensions.cs +++ b/FastGithub.ReverseProxy/ReverseProxyApplicationBuilderExtensions.cs @@ -23,13 +23,12 @@ namespace FastGithub /// /// 使用https反向代理中间件 /// - /// - /// + /// /// - public static IApplicationBuilder UseHttpsReverseProxy(this IApplicationBuilder app, string fallbackFile) + public static IApplicationBuilder UseHttpsReverseProxy(this IApplicationBuilder app) { var middleware = app.ApplicationServices.GetRequiredService(); - return app.Use(next => context => middleware.InvokeAsync(context, fallbackFile)); + return app.Use(next => context => middleware.InvokeAsync(context, next)); } } } diff --git a/FastGithub.ReverseProxy/ReverseProxyMiddleware.cs b/FastGithub.ReverseProxy/ReverseProxyMiddleware.cs index 4429472..195db6b 100644 --- a/FastGithub.ReverseProxy/ReverseProxyMiddleware.cs +++ b/FastGithub.ReverseProxy/ReverseProxyMiddleware.cs @@ -33,15 +33,14 @@ namespace FastGithub.ReverseProxy /// 处理请求 /// /// - /// + /// /// - public async Task InvokeAsync(HttpContext context, string fallbackFile) + public async Task InvokeAsync(HttpContext context, RequestDelegate next) { var host = context.Request.Host.Host; if (this.fastGithubConfig.TryGetDomainConfig(host, out var domainConfig) == false) { - context.Response.ContentType = "text/html"; - await context.Response.SendFileAsync(fallbackFile); + await next(context); } else if (domainConfig.Response != null) { diff --git a/FastGithub/Program.cs b/FastGithub/Program.cs index 61ac886..e9c6707 100644 --- a/FastGithub/Program.cs +++ b/FastGithub/Program.cs @@ -1,4 +1,6 @@ -using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -54,7 +56,13 @@ namespace FastGithub web.Configure(app => { app.UseRequestLogging(); - app.UseHttpsReverseProxy("README.html"); + app.UseHttpsReverseProxy(); + app.UseRouting(); + app.UseEndpoints(endpoints => endpoints.Map("/", async context => + { + context.Response.ContentType = "text/html"; + await context.Response.SendFileAsync("README.html"); + })); }); web.UseKestrel(kestrel => kestrel.ListenHttpsReverseProxy()); });