From 929ebce1a7c7d88e4eb3ca89e68d960d024caedd Mon Sep 17 00:00:00 2001 From: token <239573049@qq.com> Date: Wed, 24 Jan 2024 18:34:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=A0=B9=E6=8D=AE=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E7=AB=AF=E5=8F=A3=E5=A2=9E=E5=8A=A0=E7=9B=B8=E5=BA=94?= =?UTF-8?q?=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Gateway/GlobalUsing.cs | 3 ++- src/Gateway/Middlewares/StaticFileProxyMiddleware.cs | 3 ++- src/Gateway/Program.cs | 6 ++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Gateway/GlobalUsing.cs b/src/Gateway/GlobalUsing.cs index dd1cdb9..27832ea 100644 --- a/src/Gateway/GlobalUsing.cs +++ b/src/Gateway/GlobalUsing.cs @@ -23,4 +23,5 @@ global using System.Security.Claims; global using Microsoft.AspNetCore.Server.Kestrel.Core; global using System.Text; global using Microsoft.IdentityModel.Tokens; -global using System.Collections.Concurrent; \ No newline at end of file +global using System.Collections.Concurrent; +global using Microsoft.AspNetCore.Http.Features; \ No newline at end of file diff --git a/src/Gateway/Middlewares/StaticFileProxyMiddleware.cs b/src/Gateway/Middlewares/StaticFileProxyMiddleware.cs index 2fd40b1..3e6bd24 100644 --- a/src/Gateway/Middlewares/StaticFileProxyMiddleware.cs +++ b/src/Gateway/Middlewares/StaticFileProxyMiddleware.cs @@ -4,6 +4,7 @@ public class StaticFileProxyMiddleware(IContentTypeProvider contentTypeProvider) { public async Task InvokeAsync(HttpContext context, RequestDelegate next) { + context.Response.Headers["Alt-Svc"] = "h3=\":" + context.Request.Host.Port + "\""; // 如果是非GET请求,则直接跳过, /api/gateway/开头的请求也跳过 这个是属于系统内置的接口 if ((context.Request.Method != "GET" && StaticFileProxyService.StaticFileProxyEntityList.Count == 0) || context.Request.Path.Value?.StartsWith("/api/gateway/") == true) @@ -72,7 +73,7 @@ public class StaticFileProxyMiddleware(IContentTypeProvider contentTypeProvider) return; } - readfile: + readfile: // 获取文件的ContentType context.Response.ContentType = contentTypeProvider.TryGetContentType(filePath, out var contentType) diff --git a/src/Gateway/Program.cs b/src/Gateway/Program.cs index ffdb4e8..3e2b1c9 100644 --- a/src/Gateway/Program.cs +++ b/src/Gateway/Program.cs @@ -1,7 +1,5 @@ #region FreeSql类型转换 -using Microsoft.AspNetCore.Http.Features; - Utils.TypeHandlers.TryAdd(typeof(Dictionary), new StringJsonHandler>()); Utils.TypeHandlers.TryAdd(typeof(RouteMatchEntity), new StringJsonHandler()); Utils.TypeHandlers.TryAdd(typeof(List), new StringJsonHandler>()); @@ -23,7 +21,7 @@ builder.WebHost.UseKestrel(options => { // 从Certificate服务中获取 if (string.IsNullOrEmpty(name) || - !CertificateService.CertificateEntityDict.TryGetValue(name, out var certificate)) return null; + !CertificateService.CertificateEntityDict.TryGetValue(name, out var certificate)) return new X509Certificate2(); var path = Path.Combine("/data/", certificate.Path); @@ -46,7 +44,7 @@ builder.WebHost.ConfigureKestrel(kestrel => portOptions.Protocols = HttpProtocols.Http1AndHttp2AndHttp3; portOptions.UseHttps(); }); - + kestrel.ListenAnyIP(8080, portOptions => { portOptions.Protocols = HttpProtocols.Http1AndHttp2;