diff --git a/docs/src/main/asciidoc/spring-cloud-gateway.adoc b/docs/src/main/asciidoc/spring-cloud-gateway.adoc index 11a73649..a8987a06 100644 --- a/docs/src/main/asciidoc/spring-cloud-gateway.adoc +++ b/docs/src/main/asciidoc/spring-cloud-gateway.adoc @@ -188,7 +188,7 @@ spring: This route would match if the request path was, for example: `/foo/1` or `/foo/bar`. -This predicate extracts the URI template variables (like `segment` defined in the example above) as a map of names and values and places it in the `ServerWebExchange.getAttributes()` with a key defined in `PathRoutePredicate.URL_PREDICATE_VARS_ATTR`. Those values are then available for use by <> +This predicate extracts the URI template variables (like `segment` defined in the example above) as a map of names and values and places it in the `ServerWebExchange.getAttributes()` with a key defined in `ServerWebExchangeUtils.URI_TEMPLATE_VARIABLES_ATTRIBUTE`. Those values are then available for use by <> A utility method is available to make access to these variables easier. diff --git a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/SetPathGatewayFilterFactory.java b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/SetPathGatewayFilterFactory.java index d9ca270f..8a9dd50e 100644 --- a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/SetPathGatewayFilterFactory.java +++ b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/SetPathGatewayFilterFactory.java @@ -28,7 +28,7 @@ import org.springframework.web.util.UriTemplate; import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR; import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.addOriginalRequestUrl; -import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.getPathPredicateVariables; +import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.getPathMatchVariables; /** * @author Spencer Gibb @@ -54,7 +54,7 @@ public class SetPathGatewayFilterFactory extends AbstractGatewayFilterFactory uriVariables = getPathPredicateVariables(exchange); + Map uriVariables = getPathMatchVariables(exchange); URI uri = uriTemplate.expand(uriVariables); String newPath = uri.getRawPath(); diff --git a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/support/ServerWebExchangeUtils.java b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/support/ServerWebExchangeUtils.java index e5eac5a2..90a4a09e 100644 --- a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/support/ServerWebExchangeUtils.java +++ b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/support/ServerWebExchangeUtils.java @@ -127,11 +127,7 @@ public class ServerWebExchangeUtils { return t -> Mono.just(predicate.test(t)); } - public static Map getPathPredicateVariables(ServerWebExchange exchange) { - return getPathMatchVariables(exchange, URI_TEMPLATE_VARIABLES_ATTRIBUTE); - } - - public static Map getPathMatchVariables(ServerWebExchange exchange, String attr) { + public static Map getPathMatchVariables(ServerWebExchange exchange) { PathPattern.PathMatchInfo variables = exchange.getAttribute(URI_TEMPLATE_VARIABLES_ATTRIBUTE); if (variables != null) {