Hi, in the ContentNegotiation plugin of Ktor 1.x t...
# ktor
a
Hi, in the ContentNegotiation plugin of Ktor 1.x the ContentConverter interface had a method with the following signature:
Copy code
convertForSend(
        context: PipelineContext<Any, ApplicationCall>,
        contentType: ContentType,
        value: Any
    ): Any?
For my use case, the context parameter was essential. In Ktor 2.x the signature changed completely and I no longer have access to the call context when serializing:
Copy code
serializeNullable(
        contentType: ContentType,
        charset: Charset,
        typeInfo: TypeInfo,
        value: Any?
    ): OutgoingContent?
Is there any way to access the call context in Ktor 2.0?
a
Could you please describe your use case for having access to it?
a
I want to access request information like path, query params, ... in order to add links to the request body. In the end, I'm trying to create some utility for modifying responses to match the hypermedia formats like HAL.
FYI: I found no other way but to stop depending on the ContentNegotiation plugin & replicate parts of it in a custom plugin. Not very beautiful but ok somehow…
😕 1
a
Also, you can write a plugin that will combine request information with a request body, e.g. in a data class, and “push” it for the ContentNegotiation plugin.
👍 1