update 优化 WebFluxUtils.getOriginalRequestUrl 方法获取空路径报错问题

2.X
疯狂的狮子Li 2023-04-02 21:35:04 +08:00
parent d39b07aae9
commit 23c48f7624
1 changed files with 1 additions and 1 deletions

View File

@ -39,7 +39,7 @@ public class WebFluxUtils {
*/
public static String getOriginalRequestUrl(ServerWebExchange exchange) {
ServerHttpRequest request = exchange.getRequest();
LinkedHashSet<URI> uris = exchange.getRequiredAttribute(GATEWAY_ORIGINAL_REQUEST_URL_ATTR);
LinkedHashSet<URI> uris = exchange.getAttributeOrDefault(GATEWAY_ORIGINAL_REQUEST_URL_ATTR, new LinkedHashSet<>());
URI requestUri = uris.stream().findFirst().orElse(request.getURI());
return UriComponentsBuilder.fromPath(requestUri.getRawPath()).build().toUriString();
}