All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.icerockdev.webserver.tools.ApplicationReceiveFunctions.kt Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
/*
 * 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