Hong Phuc
06/16/2025, 6:57 AMoverride 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 advanceAleksei Tirman [JB]
06/16/2025, 7:31 AMHttpResponse
because the receivePipeline
is of the HttpReceivePipeline
type which has the following signature:
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.Hong Phuc
06/16/2025, 9:06 AM