Convenience for flow builders: proceeds with request and emits the resulting response elements into this FlowCollector. Useful inside flow {} blocks within interceptors.
val myAuthInterceptor = object : GrpcServerInterceptor {
override fun <Request, Response> GrpcServerCallScope<Request, Response>.intercept(
request: Flow<Request>,
): Flow<Response> =
flow {
val authorized = mySuspendAuth(requestHeaders)
if (!authorized) {
close(GrpcStatus(GrpcStatusCode.PERMISSION_DENIED, "Not authorized"))
}
proceedUnmodified(request)
}
}Content copied to clipboard