Skip to content

Commit c7639f6

Browse files
author
Anton Keks, Margo Mitt
committed
document usage of launchContext
1 parent 8f3aa33 commit c7639f6

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

docs/asciidoc/responses.adoc

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ Jooby allows you to use this experimental API by setting the `coroutineStart` op
625625
[source, kotlin]
626626
----
627627
{
628-
coroutine (CoroutineStart.UNDISPATCHED) {
628+
coroutine(CoroutineStart.UNDISPATCHED) {
629629
get("/") {
630630
val n = 5 * 5 // <1>
631631
delay(100) // <2>
@@ -639,6 +639,25 @@ Jooby allows you to use this experimental API by setting the `coroutineStart` op
639639
<2> Call a suspending function and dispatch to *worker executor*
640640
<3> Produces a response from *worker executor*
641641

642+
You can also extend the `CoroutineContext` in which the coroutine routes run:
643+
644+
.launchContext
645+
[source, kotlin]
646+
----
647+
{
648+
coroutine {
649+
launchContext { MDCContext() } // <1>
650+
651+
get("/") {
652+
...
653+
}
654+
}
655+
}
656+
----
657+
658+
<1> The lambda is run before launching each coroutine, so it can customize the `CoroutineContext` for
659+
the request, e.g. store/restore MDC, transaction, or anything else that your handlers need.
660+
642661
{love} {love}!
643662

644663
=== Send methods

0 commit comments

Comments
 (0)