class

GRPC::ServerInterceptor

Inherits Reference < Object

ServerInterceptor is the base class for server-side interceptors. Override call to wrap unary RPCs. Override the streaming variants to intercept server-streaming, client-streaming, or bidi-streaming calls. Unimplemented streaming methods default to a transparent pass-through.

Example: class AuthInterceptor < GRPC::ServerInterceptor def call(method, request, ctx, next_call) unless ctx.metadata["authorization"]? == "Bearer secret" return {Bytes.empty, GRPC::Status.new(GRPC::StatusCode::UNAUTHENTICATED, "bad token")} end next_call.call(method, request, ctx) end end

server.intercept AuthInterceptor.new

Instance methods

call(request : RequestEnvelope, ctx : ServerContext, next_call : UnaryServerCall) : ResponseEnvelope
Source
call_bidi_stream(info : CallInfo, requests : RawRequestStream, ctx : ServerContext, writer : RawResponseStream, next_call : BidiStreamServerCall) : Status
Source
call_client_stream(info : CallInfo, requests : RawRequestStream, ctx : ServerContext, next_call : ClientStreamServerCall) : ResponseEnvelope
Source
call_server_stream(request : RequestEnvelope, ctx : ServerContext, writer : RawResponseStream, next_call : ServerStreamServerCall) : Status
Source