How do you implement optional body in request hand...
# ktor
r
How do you implement optional body in request handler? There is
receiveNullable<T>()
but Ktor server still sends a 415 if I don't provide a body
Right now I have this:
Copy code
val payload =
                if (call.request.contentLength() == null || call.request.contentLength() == 0L) {
                    null
                } else {
                    call.receive<Payload>()
                }
but I really expected this to work:
Copy code
val payload = call.receiveNullable<Payload>()
e
Hey! Could you try:
Copy code
val payload = call.receiveNullable<Payload?>()
r
Exact same error. Maybe
receiveNullable
isn't meant for that use case, but I don't see any other one so I expected it to be designed for what I wanted.