Hi all, I have the following code: ```override fu...
# ktor
h
Hi all, I have the following code:
Copy code
override fun install(plugin: String, scope: HttpClient) {
            scope.receivePipeline.intercept(HttpReceivePipeline.Before) { call ->

                val cacheableResponse = CacheableResponse(call)

                println("This is ${cacheableResponse.headers}")
                proceedWith(cacheableResponse)
                }
            }
        }
how does the intercept function know that the parameter
call
is of type
HttpResponse
while the required type for the parameter in the lamdba is
TSubject
. Also how can a dev who would like to use the
intercept
function know that a
HttpResponse
can be supplied to the lamdba, and is the object supplied to the function by the framework at runtime? Thanks in advance
a
The actual type is the
HttpResponse
because the
receivePipeline
is of the
HttpReceivePipeline
type which has the following signature:
Copy code
public class HttpReceivePipeline(
    override val developmentMode: Boolean = true
) : Pipeline<HttpResponse, Unit>(Before, State, After)
The first type parameter for the
Pipeline
is the
TSubject
and the type argument that is passed is
HttpResponse
. The
TSubject
is the type of object supplied to the block as the parameter. The
TContext
is the type of the current receiver in the block.
h
I understand. Thanks @Aleksei Tirman [JB]