ktor
ktor copied to clipboard
Cannot use suspending functions in call.respondHtml
Running a suspending function in call.respondHtml will stop everything from there from rendering and being sent to the client.
https://kotlinlang.slack.com/archives/C0A974TJ9/p1496430950490462
So given a little bit more thought to this, it's not possible right now. Even if respondHtml
would accept a suspending lambda, which it can, all the builder functions for tags from kotlinx.html
are non-suspending. Can you provide a little bit more context what is a suspending function you want to call inside html building?
@orangy btw, I believe html building functions could be made inline so suspensions will work well except that writing to the output channel will be blocking (tag consumer could be suspend as well but it will have performance impact). However making functions inline leads to bytecode size growth so I am not completely sure whether it is a good idea or not.
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.