ktor-server-core / io.ktor.util / getValue

getValue

inline operator fun <reified R : Any> Parameters.getValue(thisRef: Any?, property: KProperty<*>): R

Operator function that allows to delegate variables by call parameters. It does conversion to type R using DefaultConversionService

Example

get("/") {
    val page: Int by call.request.queryParameters
    val query: String by call.request.queryParameters
    // ...
}

Exceptions

MissingRequestParameterException - if no values associated with name

ParameterConversionException - when conversion from String to R fails