@@ -110,6 +110,9 @@ sub build_handler ($controller, $destination)
110110 }
111111 }
112112
113+ # this needs to be here, since we want to use $send from this context
114+ await $ctx -> try_send_res;
115+
113116 # if this is a bridge and bridge did not render, it means we are
114117 # free to go deeper. Avoid first match, as it was handled already
115118 # above
@@ -390,27 +393,27 @@ it is equally easy to do something else. Take the following destination example:
390393
391394 async sub send_custom ($self, $ctx)
392395 {
393- await $ctx->res->text('Plaintext response');
396+ $ctx->res->text('Plaintext response');
394397 return 'this will not get rendered';
395398 }
396399
397400This takes response (L<Thunderhorse::Response> ) from context, and sends
398401plaintext manually. This action I<consumes > the context, marking it as
399- finished. In this case, return value of the destination is ignored. Note that
400- the await call on C<< ->text >> method is mandatory.
402+ finished. In this case, return value of the destination is ignored.
403+
401404
402405Another example:
403406
404407 sub send_custom2 ($self, $ctx)
405408 {
406- $ctx->res->status(400)-> content_type('text/plain');
407- return 'this is rendered as plaintext and status 400 ';
409+ $ctx->res->content_type('text/plain');
410+ return 'this is rendered as plaintext';
408411 }
409412
410413This time, the return value of the destination is not ignored, since only
411414setting response metadata does not cause the context to be consumed. Status and
412415I<Content-Type > header will not be overridden, so the response will be sent as
413- plaintext. In this case, there is no need to await anything.
416+ plaintext.
414417
415418While not very common, a destination can be unimplemented when C<to > is
416419skipped. Unimplemented locations will be "stepped over" during request
0 commit comments