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
Aleksei Tirman [JB]
10/02/2024, 7:49 AM
I would encourage users to install the
ContentNegotiation
plugin to evade implementing serialization configuration.