There are lots of Kotlin guys that don't like some parts of the syntax Javalin has.
The extension library is just a bunch of different functions to allow more Kotlin-like syntax.
Example from #150 :
Current Kotlin code:
ctx.paramMap()["id"]?.let {
...
}
Extension function:
val Context.params: Map<String, String> = this.paramMap()
ctx.params["id"].let { }
The library could be supplied as a separate artifact (eg io.javalin.k-javalin or so) to not bother the Java users.
A more natural "current vs extension" comparison would be
ctx.param("id")?.let { ... } // current
ctx.params["id"]?.let { ... } // extension
ctx.queryParam("qp")?.let { ... } // current
ctx.queryParams["qp"]?.let { ... } // extension
ctx.queryParams("qp")?.let { ... } // current
ctx.queryParamLists["qp"]?.let { ... } // extension
ctx.queryParam("qp")?.let { ... } // current
ctx.queryParams["qp"].first()?.let { ... } // extension
ctx.queryParams("qp")?.let { ... } // current
ctx.queryParams["qp"]?.let { ... } // extension
I agree, though it is not limited to context params only. Will check if the extensions can improve the syntax more significantly, as I am not sure that Javalin will benefit from these (^^^) extensions a lot.
@ShikaSD have you looked at this yet? Should we keep it open?
We can close it, the only major change affecting syntax could be some dsl in kotlin style. However, I doubt it is required for now, as personally I am fine with the dsl Javalin has with static methods.
Great, I've started thinking that keeping the library consistent across Java and Kotlin is a main goal of the project.
Most helpful comment
I agree, though it is not limited to context params only. Will check if the extensions can improve the syntax more significantly, as I am not sure that Javalin will benefit from these (^^^) extensions a lot.