https://kotlinlang.org logo
#ktor
Title
# ktor
s

S.

03/29/2022, 6:48 PM
what exactly does call.respond() do? does it end the current pipeline or should I use it with an explicit return call?
Copy code
delete("{id}") {
            val id = call.parameters["id"]?.toInt() ?: call.respondText(
                "Missing or malformed id",
                status = HttpStatusCode.BadRequest
            )
            ...
        }
vs
Copy code
delete("{id}") {
            val id = call.parameters["id"]?.toInt() ?: return@delete call.respondText(
                "Missing or malformed id",
                status = HttpStatusCode.BadRequest
            )
            ...
        }
nvm I have to, otherwise I can't use
id
a

Aleksei Tirman [JB]

03/29/2022, 9:25 PM
The
call.respond()
call executes the
ApplicationSendPipeline
that has the
Engine
phase where actual sending of a response happens.
s

S.

03/29/2022, 9:27 PM
yeah I traced it down but does it like close the request afterwards or would code after a
call.respond()
within e.g.
delete{ }
keep going?
okay now it seems like it does. I've lost myself in the coroutine debugger earlier, hence why I got weird mixed results. my bad
a

Aleksei Tirman [JB]

03/29/2022, 9:35 PM
The code will be executed after responding but a response won’t be affected.
I mean you can’t change it after responding.
s

S.

03/29/2022, 9:36 PM
ah yeah that makes sense