Created
August 23, 2017 10:15
-
-
Save fabienmoritz/b8f8239a781e89278097cca13af70341 to your computer and use it in GitHub Desktop.
easy coroutines with Jooby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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