darkmoon_uk
06/16/2019, 1:16 AMContentNegotiation
feature in the server to receive & send serialized (JSON encoded) objects?
If the expected, exact content type is specified on both server and receiver, I don't see why ContentNegotiation
needs to be a hard requirement - I thought this was only about dynamically negotiating a variable content & type at run-time?Dico
06/16/2019, 2:01 AMget("/") {
call.respond(TextContent("{\"key\": \"value\"}", contentType = ContentType.Application.Json))
}
And you can test request content type:
if (call.request.contentType() == ContentType.Application.Json) {
val text = call.receiveText()
// deserialize text
}
Dico
06/16/2019, 2:02 AM