abstract class GRPC::ServerInterceptor

Overview

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

Defined in:

grpc/interceptor.cr

Instance Method Summary

Instance Method Detail

abstract def call(request : RequestEnvelope, ctx : ServerContext, next_call : UnaryServerCall) : ResponseEnvelope #

[View source]
def call_bidi_stream(info : CallInfo, requests : RawRequestStream, ctx : ServerContext, writer : RawResponseStream, next_call : BidiStreamServerCall) : Status #

[View source]
def call_client_stream(info : CallInfo, requests : RawRequestStream, ctx : ServerContext, next_call : ClientStreamServerCall) : ResponseEnvelope #

[View source]
def call_server_stream(request : RequestEnvelope, ctx : ServerContext, writer : RawResponseStream, next_call : ServerStreamServerCall) : Status #

[View source]