perwendel / spark-kotlin

A Spark DSL in idiomatic kotlin // dependency: com.sparkjava:spark-kotlin:1.0.0-alpha
Apache License 2.0
988 stars 43 forks source link

RouteHandler::queryParams can be null #32

Open richardskg opened 6 years ago

richardskg commented 6 years ago

request.queryParams can return null, which throws a runtime error since the return type of RouteHandler.queryParams is set as a non-nullable String: fun queryParams(key: String): String { return request.queryParams(key) }

There are probably other methods with the same problem (contentType?)

mikaello commented 3 years ago

Same problem here, "solved it" by creating a wrapper function with a nullable return type:

fun Request.queryParamsNullable(queryParam: String): String? {
    return this.queryParams(queryParam)
}