Is it possible to have a set of endpoints/routes w...
# ktor
j
Is it possible to have a set of endpoints/routes with one content-types (and content negotiation) and some other routes with another content-types? I’d like to work on xmls in some application modules and jsons in some other module, and regular form-data -> html in the last module.
a
The
ContentNegotiation
plugin select a suitable converter based on the
Accept
header value. It sorts mime types by quality and the number of
*
and then takes the first matched converter. So if you want to unconditionally respond with a specific content type you have to serialize your objects explicitly without the plugin.
Actually, you can install the
ContentNegotiation
plugins into specific routes to respond with different body types.