leus
01/26/2018, 2:02 PMleus
01/26/2018, 2:04 PM@Location("/v1/check") class IntegrationsContainer
...
post<IntegrationsContainerC> { body ->
call.respond(realAppLogic(body))
}
leus
01/26/2018, 2:04 PM2018-01-26 10:59:50.226 [nettyCallPool-4-1] ERROR Application - Unhandled: POST - /v1/check
spand
01/26/2018, 2:05 PMIntegrationsContainerC
cannot be used for post variablesleus
01/26/2018, 2:05 PMspand
01/26/2018, 2:06 PMleus
01/26/2018, 2:11 PMspand
01/26/2018, 2:16 PMkristofdho
01/26/2018, 2:31 PM@Location("/")
class Post(val test: Int) //only query params
data class Body(val x: Int) //actual body
post<Post> { post ->// contains query params
val body = call.receive<Body>() // contains body
call.respond(body)
}
kristofdho
01/26/2018, 2:31 PMIntegrationsContainer
classleus
01/26/2018, 2:59 PMcall.receive<T>()
to get my actual classleus
01/26/2018, 3:02 PMBody
class above) is a complex one, can it be used? If I get a JSON body with a Content-Type: application/json
header, can I use something like Content-Negotiation feature, or should I just use a plain string / JSON serializer by hand?spand
01/26/2018, 3:03 PMclass Foo(val bar : String = "")
spand
01/26/2018, 3:04 PMkristofdho
01/26/2018, 3:09 PMkristofdho
01/26/2018, 3:09 PMleus
01/29/2018, 5:55 PMleus
01/29/2018, 5:57 PMfun Application.main() {
install(DefaultHeaders)
install(CallLogging)
install(ContentNegotiation) {
install(ContentNegotiation) {
jackson {
configure(SerializationFeature.INDENT_OUTPUT, true)
registerModule(JavaTimeModule())
}
}
}
routing {
post("/v1/check") {
try {
val myObj = call.receive<MyObject>()
call.respond(HttpStatusCode.OK)
} catch (e: Exception) {
call.respond(HttpStatusCode.BadRequest)
}
}
}
}
kristofdho
01/29/2018, 6:06 PMinstall(ContentNegotiation)
calls, just a minor oversight