Skip to content

Instantly share code, notes, and snippets.

@fabienmoritz
Created August 23, 2017 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabienmoritz/b8f8239a781e89278097cca13af70341 to your computer and use it in GitHub Desktop.
Save fabienmoritz/b8f8239a781e89278097cca13af70341 to your computer and use it in GitHub Desktop.
easy coroutines with Jooby
import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.future.future
import org.jooby.AsyncMapper
import org.jooby.run
import java.util.concurrent.TimeUnit
fun main(args:Array<String>) {
run(*args) {
map(AsyncMapper())
get("/coroutineDelay") {
future(CommonPool) {
delay(1, TimeUnit.SECONDS)
"Hello World!"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment