
com.icerockdev.webserver.tools.ApplicationReceiveFunctions.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of web-utils Show documentation
Show all versions of web-utils Show documentation
Ktor based web-server with validation and internationalization
/*
* Copyright 2020 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/
package com.icerockdev.webserver.tools
import com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException
import com.icerockdev.exception.BadRequestException
import io.ktor.application.ApplicationCall
import io.ktor.request.receive
suspend inline fun ApplicationCall.receiveRequest(): T {
return try {
receive()
} catch (e: MissingKotlinParameterException) {
throw BadRequestException(e)
} catch (e: Throwable) {
application.environment.log.error(e.localizedMessage, e)
throw BadRequestException(message = "Invalid request body")
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy