Daniel Skogquist Åborg
02/12/2021, 6:11 AMs4nchez
02/12/2021, 6:18 AMDaniel Skogquist Åborg
02/12/2021, 6:40 AM@Test
fun nullLensReturn() {
data class Input(val data: String? = null)
val app: HttpHandler = { request ->
val input = Body.auto<Input>().toLens()
val received = input(request) // not nullable, but Gson overrides this
println(received as Input? == null) // true
Response(OK, "Hello world")
}
app(Request(GET, "/").body("null"))
}
Daniel Skogquist Åborg
02/12/2021, 6:46 AMDaniel Skogquist Åborg
02/12/2021, 6:46 AMDaniel Skogquist Åborg
02/12/2021, 6:56 AMlistOf(
"[]",
"true",
"false",
"1",
) // all generate a LensFailure with "Missing/invalid parameters"
s4nchez
02/12/2021, 7:15 AMException in thread "main" org.http4k.lens.LensFailure: body 'body' must be object
at org.http4k.lens.BodyLens.invoke(body.kt:23)
at PlaygroundKt$main$app$1.invoke(playground.kt:15)
at PlaygroundKt$main$app$1.invoke(playground.kt)
at PlaygroundKt.main(playground.kt:20)
at PlaygroundKt.main(playground.kt)
Caused by: java.lang.NullPointerException: null cannot be cast to non-null type Input
at PlaygroundKt$main$app$1$$special$$inlined$auto$1.invoke(ConfigurableGson.kt:109)
at PlaygroundKt$main$app$1$$special$$inlined$auto$1.invoke(ConfigurableGson.kt)
Daniel Skogquist Åborg
02/12/2021, 7:16 AMs4nchez
02/12/2021, 7:18 AMDaniel Skogquist Åborg
02/12/2021, 7:20 AMDaniel Skogquist Åborg
02/12/2021, 7:20 AMs4nchez
02/12/2021, 7:20 AMAutoMarshallingJsonContract
as it's probably a good place to start.s4nchez
02/12/2021, 7:21 AMdave
02/12/2021, 7:51 AMDaniel Skogquist Åborg
02/12/2021, 8:57 AMs4nchez
02/12/2021, 12:39 PMDaniel Skogquist Åborg
02/12/2021, 5:48 PMDaniel Skogquist Åborg
02/13/2021, 9:10 AMdave
02/13/2021, 9:41 AMDaniel Skogquist Åborg
02/13/2021, 11:29 AMDaniel Skogquist Åborg
02/13/2021, 11:38 AMdave
02/13/2021, 11:54 AMDaniel Skogquist Åborg
02/14/2021, 6:51 AMDaniel Skogquist Åborg
02/14/2021, 7:08 AMdave
02/14/2021, 7:28 AMGrant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
Daniel Skogquist Åborg
02/14/2021, 7:30 AM