Skip to content

Commit abe3814

Browse files
committed
Add missing RequestPredicate variants in coRouter
Closes gh-32256
1 parent cc6dd19 commit abe3814

File tree

2 files changed

+78
-8
lines changed

2 files changed

+78
-8
lines changed

spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/CoRouterFunctionDsl.kt

Lines changed: 77 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,17 @@ class CoRouterFunctionDsl internal constructor (private val init: (CoRouterFunct
170170

171171
/**
172172
* Adds a route to the given handler function that handles all HTTP `GET` requests
173-
* that match the given pattern.
173+
* that match the given predicate.
174+
* @param predicate predicate to match
175+
* @since 6.1.4
176+
*/
177+
fun GET(predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse) {
178+
builder.GET(predicate, asHandlerFunction(f))
179+
}
180+
181+
/**
182+
* Adds a route to the given handler function that handles all HTTP `GET` requests
183+
* that match the given pattern and predicate.
174184
* @param pattern the pattern to match to
175185
* @param predicate additional predicate to match
176186
* @since 5.2
@@ -197,7 +207,17 @@ class CoRouterFunctionDsl internal constructor (private val init: (CoRouterFunct
197207

198208
/**
199209
* Adds a route to the given handler function that handles all HTTP `HEAD` requests
200-
* that match the given pattern.
210+
* that match the given pattern and predicate.
211+
* @param predicate predicate to match
212+
* @since 6.1.4
213+
*/
214+
fun HEAD(predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse) {
215+
builder.HEAD(predicate, asHandlerFunction(f))
216+
}
217+
218+
/**
219+
* Adds a route to the given handler function that handles all HTTP `HEAD` requests
220+
* that match the given pattern and predicate.
201221
* @param pattern the pattern to match to
202222
* @param predicate additional predicate to match
203223
* @since 5.2
@@ -224,7 +244,17 @@ class CoRouterFunctionDsl internal constructor (private val init: (CoRouterFunct
224244

225245
/**
226246
* Adds a route to the given handler function that handles all HTTP `POST` requests
227-
* that match the given pattern.
247+
* that match the given predicate.
248+
* @param predicate predicate to match
249+
* @since 6.1.4
250+
*/
251+
fun POST(predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse) {
252+
builder.POST(predicate, asHandlerFunction(f))
253+
}
254+
255+
/**
256+
* Adds a route to the given handler function that handles all HTTP `POST` requests
257+
* that match the given pattern and predicate.
228258
* @param pattern the pattern to match to
229259
* @param predicate additional predicate to match
230260
* @since 5.2
@@ -251,7 +281,17 @@ class CoRouterFunctionDsl internal constructor (private val init: (CoRouterFunct
251281

252282
/**
253283
* Adds a route to the given handler function that handles all HTTP `PUT` requests
254-
* that match the given pattern.
284+
* that match the given predicate.
285+
* @param predicate predicate to match
286+
* @since 6.1.4
287+
*/
288+
fun PUT(predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse) {
289+
builder.PUT(predicate, asHandlerFunction(f))
290+
}
291+
292+
/**
293+
* Adds a route to the given handler function that handles all HTTP `PUT` requests
294+
* that match the given pattern and predicate.
255295
* @param pattern the pattern to match to
256296
* @param predicate additional predicate to match
257297
* @since 5.2
@@ -278,7 +318,17 @@ class CoRouterFunctionDsl internal constructor (private val init: (CoRouterFunct
278318

279319
/**
280320
* Adds a route to the given handler function that handles all HTTP `PATCH` requests
281-
* that match the given pattern.
321+
* that match the given pattern and predicate.
322+
* @param predicate predicate to match
323+
* @since 6.1.4
324+
*/
325+
fun PATCH(predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse) {
326+
builder.PATCH(predicate, asHandlerFunction(f))
327+
}
328+
329+
/**
330+
* Adds a route to the given handler function that handles all HTTP `PATCH` requests
331+
* that match the given pattern and predicate.
282332
* @param pattern the pattern to match to
283333
* @param predicate additional predicate to match
284334
* @since 5.2
@@ -307,7 +357,17 @@ class CoRouterFunctionDsl internal constructor (private val init: (CoRouterFunct
307357

308358
/**
309359
* Adds a route to the given handler function that handles all HTTP `DELETE` requests
310-
* that match the given pattern.
360+
* that match the given predicate.
361+
* @param predicate predicate to match
362+
* @since 6.1.4
363+
*/
364+
fun DELETE(predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse) {
365+
builder.DELETE(predicate, asHandlerFunction(f))
366+
}
367+
368+
/**
369+
* Adds a route to the given handler function that handles all HTTP `DELETE` requests
370+
* that match the given pattern and predicate.
311371
* @param pattern the pattern to match to
312372
* @param predicate additional predicate to match
313373
* @since 5.2
@@ -336,7 +396,17 @@ class CoRouterFunctionDsl internal constructor (private val init: (CoRouterFunct
336396

337397
/**
338398
* Adds a route to the given handler function that handles all HTTP `OPTIONS` requests
339-
* that match the given pattern.
399+
* that match the given predicate.
400+
* @param predicate predicate to match
401+
* @since 6.1.4
402+
*/
403+
fun OPTIONS(predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse) {
404+
builder.OPTIONS(predicate, asHandlerFunction(f))
405+
}
406+
407+
/**
408+
* Adds a route to the given handler function that handles all HTTP `OPTIONS` requests
409+
* that match the given pattern and predicate.
340410
* @param pattern the pattern to match to
341411
* @param predicate additional predicate to match
342412
* @since 5.2

spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/CoRouterFunctionDslTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ class CoRouterFunctionDslTests {
333333
null
334334
}
335335
}
336-
GET("/**", pathExtension { it == "properties" }) {
336+
GET(pathExtension { it == "properties" }) {
337337
ok().bodyValueAndAwait("foo=bar")
338338
}
339339
path("/baz", ::handle)

0 commit comments

Comments
 (0)