parent
0da8dee289
commit
03f34e24ca
|
|
@ -69,6 +69,9 @@ class RouterDsl {
|
|||
|
||||
operator fun RequestPredicate.not(): RequestPredicate = this.negate()
|
||||
|
||||
fun RequestPredicate.route(routes: RouterDsl.() -> Unit) =
|
||||
RouterFunctions.nest(this, RouterDsl().apply(routes).router())
|
||||
|
||||
operator fun RequestPredicate.invoke(f: (ServerRequest) -> Mono<ServerResponse>) {
|
||||
routes += RouterFunctions.route(this, HandlerFunction { f(it) })
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,15 +112,15 @@ class RouterFunctionExtensionsTests {
|
|||
|
||||
override fun route(req: ServerRequest) = route(req) {
|
||||
(GET("/foo/") or GET("/foos/")) { handle(req) }
|
||||
accept(APPLICATION_JSON).apply {
|
||||
POST("/api/foo/") { handleFromClass(req) }
|
||||
PUT("/api/foo/") { handleFromClass(req) }
|
||||
DELETE("/api/foo/") { handleFromClass(req) }
|
||||
(pathPrefix("/api") and accept(APPLICATION_JSON)).route {
|
||||
POST("/foo/") { handleFromClass(req) }
|
||||
PUT("/foo/") { handleFromClass(req) }
|
||||
DELETE("/foo/") { handleFromClass(req) }
|
||||
}
|
||||
accept(APPLICATION_ATOM_XML, ::handle)
|
||||
contentType(APPLICATION_OCTET_STREAM) { handle(req) }
|
||||
method(HttpMethod.PATCH) { handle(req) }
|
||||
headers({ it.accept().contains(APPLICATION_JSON) }).apply {
|
||||
headers({ it.accept().contains(APPLICATION_JSON) }).route {
|
||||
GET("/api/foo/", ::handle)
|
||||
}
|
||||
headers({ it.header("bar").isNotEmpty() }, ::handle)
|
||||
|
|
|
|||
Loading…
Reference in New Issue