From 725790148de01a0f7ff05f725c78798bf4160d98 Mon Sep 17 00:00:00 2001 From: Mariia Skripchenko <61115099+marychatte@users.noreply.github.com> Date: Tue, 26 Nov 2024 16:35:16 +0100 Subject: [PATCH] KTOR-7276 Allow suspend function in ResponseSent hook --- ktor-server/ktor-server-core/api/ktor-server-core.api | 2 +- ktor-server/ktor-server-core/api/ktor-server-core.klib.api | 4 ++-- .../src/io/ktor/server/application/hooks/CommonHooks.kt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ktor-server/ktor-server-core/api/ktor-server-core.api b/ktor-server/ktor-server-core/api/ktor-server-core.api index 59586e5d9c4..3782ca7fc75 100644 --- a/ktor-server/ktor-server-core/api/ktor-server-core.api +++ b/ktor-server/ktor-server-core/api/ktor-server-core.api @@ -267,7 +267,7 @@ public final class io/ktor/server/application/hooks/ResponseBodyReadyForSend$Con public final class io/ktor/server/application/hooks/ResponseSent : io/ktor/server/application/Hook { public static final field INSTANCE Lio/ktor/server/application/hooks/ResponseSent; public synthetic fun install (Lio/ktor/server/application/ApplicationCallPipeline;Ljava/lang/Object;)V - public fun install (Lio/ktor/server/application/ApplicationCallPipeline;Lkotlin/jvm/functions/Function1;)V + public fun install (Lio/ktor/server/application/ApplicationCallPipeline;Lkotlin/jvm/functions/Function2;)V } public abstract interface class io/ktor/server/config/ApplicationConfig { diff --git a/ktor-server/ktor-server-core/api/ktor-server-core.klib.api b/ktor-server/ktor-server-core/api/ktor-server-core.klib.api index 75e902b0407..cd6c9457f5d 100644 --- a/ktor-server/ktor-server-core/api/ktor-server-core.klib.api +++ b/ktor-server/ktor-server-core/api/ktor-server-core.klib.api @@ -1555,8 +1555,8 @@ final object io.ktor.server.application.hooks/ResponseBodyReadyForSend : io.ktor } } -final object io.ktor.server.application.hooks/ResponseSent : io.ktor.server.application/Hook> { // io.ktor.server.application.hooks/ResponseSent|null[0] - final fun install(io.ktor.server.application/ApplicationCallPipeline, kotlin/Function1) // io.ktor.server.application.hooks/ResponseSent.install|install(io.ktor.server.application.ApplicationCallPipeline;kotlin.Function1){}[0] +final object io.ktor.server.application.hooks/ResponseSent : io.ktor.server.application/Hook> { // io.ktor.server.application.hooks/ResponseSent|null[0] + final fun install(io.ktor.server.application/ApplicationCallPipeline, kotlin.coroutines/SuspendFunction1) // io.ktor.server.application.hooks/ResponseSent.install|install(io.ktor.server.application.ApplicationCallPipeline;kotlin.coroutines.SuspendFunction1){}[0] } final object io.ktor.server.engine/ConfigKeys { // io.ktor.server.engine/ConfigKeys|null[0] diff --git a/ktor-server/ktor-server-core/common/src/io/ktor/server/application/hooks/CommonHooks.kt b/ktor-server/ktor-server-core/common/src/io/ktor/server/application/hooks/CommonHooks.kt index 8bab62fa1b4..d8923005cc4 100644 --- a/ktor-server/ktor-server-core/common/src/io/ktor/server/application/hooks/CommonHooks.kt +++ b/ktor-server/ktor-server-core/common/src/io/ktor/server/application/hooks/CommonHooks.kt @@ -110,8 +110,8 @@ public object ResponseBodyReadyForSend : * A hook that is invoked when response was successfully sent to a client. * Useful for cleaning up opened resources or finishing measurements. */ -public object ResponseSent : Hook<(ApplicationCall) -> Unit> { - override fun install(pipeline: ApplicationCallPipeline, handler: (ApplicationCall) -> Unit) { +public object ResponseSent : Hook Unit> { + override fun install(pipeline: ApplicationCallPipeline, handler: suspend (ApplicationCall) -> Unit) { pipeline.sendPipeline.intercept(ApplicationSendPipeline.Engine) { proceed() handler(call)