This example demonstrates how to use the container's
Asynchronous (continuation) response capabilities such
that no I/O threads are consumed during the calculation
of the REST response value.
Click to see the response
after a 2 second delay.
object AsyncRest extends RestHelper {
serve {
case "async" :: id :: _ Get _ =>
RestContinuation.async(
reply => {
Thread.sleep(2000) val name1 = Thread.currentThread.getName
val outerSesStr = S.session.toString
reply{
val name2 = Thread.currentThread.getName
val innerSesStr = S.session.toString <i id={id}>name1: {name1} outer: {outerSesStr} name2: {name2}
inner: {innerSesStr}</i>
}
})
}
}