diff --git a/multi/multi_gateway-request-predicates-factories.html b/multi/multi_gateway-request-predicates-factories.html index bbaf6cf6..e7248e8f 100644 --- a/multi/multi_gateway-request-predicates-factories.html +++ b/multi/multi_gateway-request-predicates-factories.html @@ -72,7 +72,9 @@ uri: http://example.org predicates: - Path=/foo/{segment},/bar/{segment}
-
This route would match if the request path was, for example: /foo/1 or /foo/bar or /bar/baz.
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 GatewayFilter Factories
The Query Route Predicate Factory takes two parameters: a required param and an optional regexp.
application.yml. +
This route would match if the request path was, for example: /foo/1 or /foo/bar or /bar/baz.
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 GatewayFilter Factories
A utility method is available to make access to these variables easier.
Map<String, String> uriVariables = ServerWebExchangeUtils.getPathPredicateVariables(exchange);
+
+String segment = uriVariables.get("segment");The Query Route Predicate Factory takes two parameters: a required param and an optional regexp.
application.yml.
spring: cloud: gateway: diff --git a/single/spring-cloud-gateway.html b/single/spring-cloud-gateway.html index ca2704b3..0564ed4f 100644 --- a/single/spring-cloud-gateway.html +++ b/single/spring-cloud-gateway.html @@ -74,7 +74,9 @@ for details on setting up your build system with the current Spring Cloud Releas uri: http://example.org predicates: - Path=/foo/{segment},/bar/{segment}
-
This route would match if the request path was, for example: /foo/1 or /foo/bar or /bar/baz.
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 GatewayFilter Factories
The Query Route Predicate Factory takes two parameters: a required param and an optional regexp.
application.yml. +
This route would match if the request path was, for example: /foo/1 or /foo/bar or /bar/baz.
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 GatewayFilter Factories
A utility method is available to make access to these variables easier.
Map<String, String> uriVariables = ServerWebExchangeUtils.getPathPredicateVariables(exchange);
+
+String segment = uriVariables.get("segment");The Query Route Predicate Factory takes two parameters: a required param and an optional regexp.
application.yml.
spring: cloud: gateway: diff --git a/spring-cloud-gateway.xml b/spring-cloud-gateway.xml index a54ca14b..69086e3e 100644 --- a/spring-cloud-gateway.xml +++ b/spring-cloud-gateway.xml @@ -197,6 +197,10 @@ for details on setting up your build system with the current Spring Cloud ReleasThis route would match if the request path was, for example: /foo/1 or/foo/bar or/bar/baz .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 theServerWebExchange.getAttributes() with a key defined inPathRoutePredicate.URL_PREDICATE_VARS_ATTR . Those values are then available for use by GatewayFilter FactoriesA utility method is available to make access to these variables easier. +Map<String, String> uriVariables = ServerWebExchangeUtils.getPathPredicateVariables(exchange); + +String segment = uriVariables.get("segment"); Query Route Predicate Factory