You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Document Path predicate fully expanded argument format
Add documentation for using the Path predicate with fully expanded
arguments, including indexed key notation (patterns.0, patterns.1)
for list parameters. This clarifies the naming convention when
configuring routes via the Actuator API or programmatically.
Fixesgh-3523
When using the fully expanded argument format (for example, when configuring routes via the Actuator API or programmatically), the `Path` predicate uses indexed keys for list parameters. The following example shows the fully expanded configuration:
215
+
216
+
.application.yml
217
+
[source,yaml]
218
+
----
219
+
spring:
220
+
cloud:
221
+
gateway:
222
+
server:
223
+
webflux:
224
+
routes:
225
+
- id: path_route
226
+
uri: https://example.org
227
+
predicates:
228
+
- name: Path
229
+
args:
230
+
patterns.0: /red/{segment}
231
+
patterns.1: /blue/{segment}
232
+
matchTrailingSlash: false
233
+
----
234
+
235
+
When posting route definitions via the Actuator API, use the same indexed notation in the JSON request body:
236
+
237
+
[source,json]
238
+
----
239
+
{
240
+
"id": "path_route",
241
+
"uri": "https://example.org",
242
+
"predicates": [
243
+
{
244
+
"name": "Path",
245
+
"args": {
246
+
"patterns.0": "/red/{segment}",
247
+
"patterns.1": "/blue/{segment}",
248
+
"matchTrailingSlash": "false"
249
+
}
250
+
}
251
+
]
252
+
}
253
+
----
254
+
255
+
NOTE: The `args` map accepts only `String` key-value pairs. List parameters like `patterns` must be specified using indexed keys (`patterns.0`, `patterns.1`, etc.) rather than JSON arrays. This indexed notation is automatically converted to a `List<String>` when the predicate is configured.
256
+
211
257
If you have set `spring.webflux.base-path` property, this will influence the path matching. The property value will be automatically prepended to the path patterns. For example, with `spring.webflux.base-path=/app` and a path pattern of `/red/\{segment\}`, the full pattern used for matching would be `/app/red/\{segment\}`.
212
258
213
259
This predicate extracts the URI template variables (such as `segment`, defined in the preceding example) as a map of names and values and places it in the `ServerWebExchange.getAttributes()` with a key defined in `ServerWebExchangeUtils.URI_TEMPLATE_VARIABLES_ATTRIBUTE`.
0 commit comments