You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a situation when optional additional handling of a content of a server response in generated API classes by moko-network-generator plugin is needed.
I need to pass some lambda or fun interface into constructor of *Impl classes. Then the lambda will be called after results receiving and before serialization process (here before 131 line):
Use case: HTTP-server responds with errors using HTTP status 200 and there is some data of the error in the request body. As I understand it, at the moment there is no way to handle such thing using Ktor features because of io.ktor.client.call.DoubleReceiveException.
The text was updated successfully, but these errors were encountered:
@Tetraquark hi! i think your case can be solved by something like Logger ktor feature. in this feature all content received (for logs) and later it passed to next pipeline step (just as copy as i know)
scope.receivePipeline.intercept(HttpReceivePipeline.After) { response ->
val charset = response.contentType()?.charset() ?: Charsets.UTF_8
// Get body from content
val body = response.content.readRemaining().readText(
charset = charset
)
// Processing body
val result = handleBody(body)
if (result) {
// Just proceed pipeline
val byteChannel = ByteReadChannel(
body.toByteArray(charset)
)
proceedWith(context.wrapWithContent(byteChannel).response)
} else {
throw Exception()
}
}
There is a situation when optional additional handling of a content of a server response in generated API classes by moko-network-generator plugin is needed.
I need to pass some lambda or
fun interface
into constructor of*Impl
classes. Then the lambda will be called after results receiving and before serialization process (here before 131 line):moko-network/network-generator/src/main/resources/kotlin-ktor-client/api.mustache
Line 131 in 1b6bf98
Use case: HTTP-server responds with errors using HTTP status 200 and there is some data of the error in the request body. As I understand it, at the moment there is no way to handle such thing using Ktor features because of
io.ktor.client.call.DoubleReceiveException
.The text was updated successfully, but these errors were encountered: