Sha256: bc78e7cae6a9051389162276f62a51b40c03e40f01ac37f9c26d4fa69049360e
Contents?: true
Size: 1017 Bytes
Versions: 14
Compression:
Stored size: 1017 Bytes
Contents
# frozen_string_literal: true require 'grpc_kit/interceptors' require 'grpc_kit/interceptor_registory' module GrpcKit module Interceptors::Server class RequestResponse # @param interceptors [Array<GrpcKit::Grpc::ServerInterceptor>] def initialize(interceptors) @registry = GrpcKit::InterceptorRegistry.new(interceptors) end # @param request [Object] Recevied request objects # @param call [GrpcKit::Calls::Client::RequestResponse] # @yieldreturn [Object] Response object server sent def intercept(request, call, &block) do_intercept(@registry.build, request, call, &block) end private def do_intercept(interceptors, request, call) if interceptors.empty? return yield end interceptor = interceptors.pop interceptor.request_response(request: request, call: call, method: call.method) do do_intercept(interceptors, request, call) { yield } end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems