convertForSend

abstract suspend fun convertForSend(context: PipelineContext<Any, ApplicationCall>, contentType: ContentType, value: Any): Any?

Convert a value to the specified contentType to a value suitable for sending (serialize). Note that as far as ContentConverter could be registered multiple times with different content types hence contentType could be different depends on what the client accepts (inferred from Accept header). This function could ignore value if it is not suitable for conversion and return null so in this case other registered converters could be tried or this function could be invoked with other content types it the converted has been registered multiple times with different content types

Return

a converted value (possibly an OutgoingContent), or null if value isn't suitable for this converter

Parameters

context

pipeline context

contentType

to which this data converted has been registered and that matches client's accept header

value

to be converted