s4nchez
06/19/2018, 2:14 PMimport org.http4k.core.Method
import org.http4k.core.Request
import org.http4k.core.Response
import org.http4k.core.Status.Companion.OK
import org.http4k.routing.bind
import org.http4k.routing.routes
fun main(args: Array<String>) {
val existingApp = routes(
"/legacy" bind { _: Request -> Response(OK).body("legacy") },
"/api" bind routes(
"v1" bind { _: Request -> Response(OK).body("v1") })
)
val handler = routes(
existingApp,
"/more" bind { _: Request -> Response(OK).body("more") }
)
println(handler(Request(Method.GET, "/other")).bodyString()) //404
println(handler(Request(Method.GET, "/legacy")).bodyString()) //legacy
println(handler(Request(Method.GET, "/api/v1")).bodyString()) //v1
println(handler(Request(Method.GET, "/more")).bodyString()) //more
}