Add support for empty router in RouterFunctionDsl
Issue: SPR-17247
This commit is contained in:
parent
f8a0e3d084
commit
48c660fa41
|
|
@ -546,7 +546,12 @@ open class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) : (
|
|||
*/
|
||||
override fun invoke(): RouterFunction<ServerResponse> {
|
||||
init()
|
||||
return routes.reduce(RouterFunction<ServerResponse>::and)
|
||||
return if (routes.isEmpty()) {
|
||||
RouterFunction<ServerResponse> { Mono.empty() }
|
||||
}
|
||||
else {
|
||||
routes.reduce(RouterFunction<ServerResponse>::and)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -120,6 +120,11 @@ class RouterFunctionDslTests {
|
|||
.verifyComplete()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun emptyRouter() {
|
||||
router { }
|
||||
}
|
||||
|
||||
|
||||
private fun sampleRouter() = router {
|
||||
(GET("/foo/") or GET("/foos/")) { req -> handle(req) }
|
||||
|
|
|
|||
Loading…
Reference in New Issue