Fixes constant documentation reference for Path Route Predicate.

Also aligns to a new constant name.

fixes gh-708
This commit is contained in:
Spencer Gibb
2018-12-10 22:19:07 -05:00
parent 4a987fd6a4
commit 8194137f03
3 changed files with 4 additions and 8 deletions

View File

@@ -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 <<gateway-route-filters,GatewayFilter Factories>>
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 <<gateway-route-filters,GatewayFilter Factories>>
A utility method is available to make access to these variables easier.

View File

@@ -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<Se
ServerHttpRequest req = exchange.getRequest();
addOriginalRequestUrl(exchange, req.getURI());
Map<String, String> uriVariables = getPathPredicateVariables(exchange);
Map<String, String> uriVariables = getPathMatchVariables(exchange);
URI uri = uriTemplate.expand(uriVariables);
String newPath = uri.getRawPath();

View File

@@ -127,11 +127,7 @@ public class ServerWebExchangeUtils {
return t -> Mono.just(predicate.test(t));
}
public static Map<String, String> getPathPredicateVariables(ServerWebExchange exchange) {
return getPathMatchVariables(exchange, URI_TEMPLATE_VARIABLES_ATTRIBUTE);
}
public static Map<String, String> getPathMatchVariables(ServerWebExchange exchange, String attr) {
public static Map<String, String> getPathMatchVariables(ServerWebExchange exchange) {
PathPattern.PathMatchInfo variables = exchange.getAttribute(URI_TEMPLATE_VARIABLES_ATTRIBUTE);
if (variables != null) {