Add missing RequestPredicate variants in coRouter

Closes gh-32256
This commit is contained in:
Sébastien Deleuze
2024-02-13 14:50:49 +01:00
parent cc6dd19324
commit abe381488a
2 changed files with 78 additions and 8 deletions

View File

@@ -170,7 +170,17 @@ class CoRouterFunctionDsl internal constructor (private val init: (CoRouterFunct
/**
* Adds a route to the given handler function that handles all HTTP `GET` requests
* that match the given pattern.
* that match the given predicate.
* @param predicate predicate to match
* @since 6.1.4
*/
fun GET(predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse) {
builder.GET(predicate, asHandlerFunction(f))
}
/**
* Adds a route to the given handler function that handles all HTTP `GET` requests
* that match the given pattern and predicate.
* @param pattern the pattern to match to
* @param predicate additional predicate to match
* @since 5.2
@@ -197,7 +207,17 @@ class CoRouterFunctionDsl internal constructor (private val init: (CoRouterFunct
/**
* Adds a route to the given handler function that handles all HTTP `HEAD` requests
* that match the given pattern.
* that match the given pattern and predicate.
* @param predicate predicate to match
* @since 6.1.4
*/
fun HEAD(predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse) {
builder.HEAD(predicate, asHandlerFunction(f))
}
/**
* Adds a route to the given handler function that handles all HTTP `HEAD` requests
* that match the given pattern and predicate.
* @param pattern the pattern to match to
* @param predicate additional predicate to match
* @since 5.2
@@ -224,7 +244,17 @@ class CoRouterFunctionDsl internal constructor (private val init: (CoRouterFunct
/**
* Adds a route to the given handler function that handles all HTTP `POST` requests
* that match the given pattern.
* that match the given predicate.
* @param predicate predicate to match
* @since 6.1.4
*/
fun POST(predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse) {
builder.POST(predicate, asHandlerFunction(f))
}
/**
* Adds a route to the given handler function that handles all HTTP `POST` requests
* that match the given pattern and predicate.
* @param pattern the pattern to match to
* @param predicate additional predicate to match
* @since 5.2
@@ -251,7 +281,17 @@ class CoRouterFunctionDsl internal constructor (private val init: (CoRouterFunct
/**
* Adds a route to the given handler function that handles all HTTP `PUT` requests
* that match the given pattern.
* that match the given predicate.
* @param predicate predicate to match
* @since 6.1.4
*/
fun PUT(predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse) {
builder.PUT(predicate, asHandlerFunction(f))
}
/**
* Adds a route to the given handler function that handles all HTTP `PUT` requests
* that match the given pattern and predicate.
* @param pattern the pattern to match to
* @param predicate additional predicate to match
* @since 5.2
@@ -278,7 +318,17 @@ class CoRouterFunctionDsl internal constructor (private val init: (CoRouterFunct
/**
* Adds a route to the given handler function that handles all HTTP `PATCH` requests
* that match the given pattern.
* that match the given pattern and predicate.
* @param predicate predicate to match
* @since 6.1.4
*/
fun PATCH(predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse) {
builder.PATCH(predicate, asHandlerFunction(f))
}
/**
* Adds a route to the given handler function that handles all HTTP `PATCH` requests
* that match the given pattern and predicate.
* @param pattern the pattern to match to
* @param predicate additional predicate to match
* @since 5.2
@@ -307,7 +357,17 @@ class CoRouterFunctionDsl internal constructor (private val init: (CoRouterFunct
/**
* Adds a route to the given handler function that handles all HTTP `DELETE` requests
* that match the given pattern.
* that match the given predicate.
* @param predicate predicate to match
* @since 6.1.4
*/
fun DELETE(predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse) {
builder.DELETE(predicate, asHandlerFunction(f))
}
/**
* Adds a route to the given handler function that handles all HTTP `DELETE` requests
* that match the given pattern and predicate.
* @param pattern the pattern to match to
* @param predicate additional predicate to match
* @since 5.2
@@ -336,7 +396,17 @@ class CoRouterFunctionDsl internal constructor (private val init: (CoRouterFunct
/**
* Adds a route to the given handler function that handles all HTTP `OPTIONS` requests
* that match the given pattern.
* that match the given predicate.
* @param predicate predicate to match
* @since 6.1.4
*/
fun OPTIONS(predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse) {
builder.OPTIONS(predicate, asHandlerFunction(f))
}
/**
* Adds a route to the given handler function that handles all HTTP `OPTIONS` requests
* that match the given pattern and predicate.
* @param pattern the pattern to match to
* @param predicate additional predicate to match
* @since 5.2

View File

@@ -333,7 +333,7 @@ class CoRouterFunctionDslTests {
null
}
}
GET("/**", pathExtension { it == "properties" }) {
GET(pathExtension { it == "properties" }) {
ok().bodyValueAndAwait("foo=bar")
}
path("/baz", ::handle)