#26 fix RoutePrefix nginx代理路径无效的问题

This commit is contained in:
luoyunchong 2021-10-23 00:13:05 +08:00
parent 1e9fb7d195
commit 99fd092b24

View File

@ -45,6 +45,7 @@ namespace IGeekFan.AspNetCore.Knife4jUI
public async Task Invoke(HttpContext httpContext) public async Task Invoke(HttpContext httpContext)
{ {
var httpMethod = httpContext.Request.Method; var httpMethod = httpContext.Request.Method;
var path = httpContext.Request.Path.Value; var path = httpContext.Request.Path.Value;
@ -66,7 +67,7 @@ namespace IGeekFan.AspNetCore.Knife4jUI
return; return;
} }
if (httpMethod == "GET" && Regex.IsMatch(path, $"^/swagger-resources$")) if (httpMethod == "GET" && Regex.IsMatch(path, $"/swagger-resources$"))
{ {
await RespondWithConfig(httpContext.Response); await RespondWithConfig(httpContext.Response);
return; return;
@ -74,7 +75,7 @@ namespace IGeekFan.AspNetCore.Knife4jUI
await _staticFileMiddleware.Invoke(httpContext); await _staticFileMiddleware.Invoke(httpContext);
} }
private async Task RespondWithConfig(HttpResponse response) private async Task RespondWithConfig(HttpResponse response)
{ {
await response.WriteAsync(JsonSerializer.Serialize(_options.ConfigObject.Urls, _jsonSerializerOptions)); await response.WriteAsync(JsonSerializer.Serialize(_options.ConfigObject.Urls, _jsonSerializerOptions));