I'm writing a Ktor plugin capable of sending an HT...
# ktor
j
I'm writing a Ktor plugin capable of sending an HTTP response when catching a specific exception. The response body is a serializable class. Should I serialize the class within the plugin code, using kotlinx.serialization? Which means I would write something like
call.respond(Json.encodeToString(bodyClass))
. However the user has no way to choose another format like XML. Or should I encourage my users to configure the Content Negotiation plugin to serialize the class? Then I would write something like
call.respond(bodyClass)
and serialization will be automatically handled. However, this code will fail if the Content Negociation plugin isn't configured.
a
I would encourage users to install the
ContentNegotiation
plugin to evade implementing serialization configuration.
j
That’s what I was leaning to, thanks!