mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2026-11-07 12:33:38 +00:00
bodyOrNull/respondOrNoContent
This commit is contained in:
1 parent
2cc6126765
commit
ac58b6a7e3
3 files changed
+30
No files matched your search
@@ -0,0 +1,15 @@
|
||||
package dev.inmo.micro_utils.ktor.server
|
||||
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.server.application.ApplicationCall
|
||||
import io.ktor.server.response.respond
|
||||
|
||||
suspend inline fun <reified T : Any> ApplicationCall.respondOrNoContent(
|
||||
data: T?
|
||||
) {
|
||||
if (data == null) {
|
||||
respond(HttpStatusCode.NoContent)
|
||||
} else {
|
||||
respond(data)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user