dave
03/04/2019, 1:50 PM@Test
fun `should allow nesting routes`() {
val definitely = listOf(routes("/hello" bind GET to { Response(OK).body("hello") }))
val maybe = if (true)
listOf(
routes("/service" bind
routes(
"/hello" bind GET to { Response(OK).body("service/hello") },
"/bob" bind GET to { Response(OK).body("service/bobs") }
)
)
) else emptyList()
val routes = routes(*(definitely + maybe).toTypedArray())
assertEquals(routes(Request(GET, "/hello")).status, OK)
assertEquals(routes(Request(GET, "/service/hello")).status, OK)
assertEquals(routes(Request(GET, "/service/bob")).status, OK)
}