Table of Contents

Class AuthorizationInterceptor

Namespace
Arc4u.gRPC.Interceptors
Assembly
Arc4u.gRPC.dll

Server interceptor that prepares the Arc4u context of a call and hides unexpected server errors.

public class AuthorizationInterceptor : Interceptor
Inheritance
AuthorizationInterceptor
Inherited Members

Remarks

For each unary, server-streaming and duplex call (client-streaming calls are not intercepted) it applies the culture request header (when present and a principal exists) to the current thread and to the principal profile. Duplex calls on /grpc.reflection are left untouched. An RpcException thrown by the service is logged and rethrown; any other exception is logged and replaced by an Internal status with a generic message.

Constructors

AuthorizationInterceptor(ILogger<AuthorizationInterceptor>, IApplicationContext)

Server interceptor that prepares the Arc4u context of a call and hides unexpected server errors.

public AuthorizationInterceptor(ILogger<AuthorizationInterceptor> logger, IApplicationContext applicationContext)

Parameters

logger ILogger<AuthorizationInterceptor>
applicationContext IApplicationContext

Remarks

For each unary, server-streaming and duplex call (client-streaming calls are not intercepted) it applies the culture request header (when present and a principal exists) to the current thread and to the principal profile. Duplex calls on /grpc.reflection are left untouched. An RpcException thrown by the service is logged and rethrown; any other exception is logged and replaced by an Internal status with a generic message.

Methods

DuplexStreamingServerHandler<TRequest, TResponse>(IAsyncStreamReader<TRequest>, IServerStreamWriter<TResponse>, ServerCallContext, DuplexStreamingServerMethod<TRequest, TResponse>)

Server-side handler for intercepting bidirectional streaming calls.

public override Task DuplexStreamingServerHandler<TRequest, TResponse>(IAsyncStreamReader<TRequest> requestStream, IServerStreamWriter<TResponse> responseStream, ServerCallContext context, DuplexStreamingServerMethod<TRequest, TResponse> continuation) where TRequest : class where TResponse : class

Parameters

requestStream IAsyncStreamReader<TRequest>

The request stream of the incoming invocation.

responseStream IServerStreamWriter<TResponse>

The response stream of the incoming invocation.

context ServerCallContext

An instance of ServerCallContext representing the context of the invocation.

continuation DuplexStreamingServerMethod<TRequest, TResponse>

A delegate that asynchronously proceeds with the invocation, calling the next interceptor in the chain, or the service request handler, in case of the last interceptor and the interceptor can choose to call it zero or more times at its discretion. The interceptor has the ability to wrap or substitute the request and response streams when calling the continuation.

Returns

Task

Type Parameters

TRequest

Request message type for this method.

TResponse

Response message type for this method.

ServerStreamingServerHandler<TRequest, TResponse>(TRequest, IServerStreamWriter<TResponse>, ServerCallContext, ServerStreamingServerMethod<TRequest, TResponse>)

Server-side handler for intercepting server streaming call.

public override Task ServerStreamingServerHandler<TRequest, TResponse>(TRequest request, IServerStreamWriter<TResponse> responseStream, ServerCallContext context, ServerStreamingServerMethod<TRequest, TResponse> continuation) where TRequest : class where TResponse : class

Parameters

request TRequest

The request value of the incoming invocation.

responseStream IServerStreamWriter<TResponse>

The response stream of the incoming invocation.

context ServerCallContext

An instance of ServerCallContext representing the context of the invocation.

continuation ServerStreamingServerMethod<TRequest, TResponse>

A delegate that asynchronously proceeds with the invocation, calling the next interceptor in the chain, or the service request handler, in case of the last interceptor and the interceptor can choose to call it zero or more times at its discretion. The interceptor has the ability to wrap or substitute the request value and the response stream when calling the continuation.

Returns

Task

Type Parameters

TRequest

Request message type for this method.

TResponse

Response message type for this method.

UnaryServerHandler<TRequest, TResponse>(TRequest, ServerCallContext, UnaryServerMethod<TRequest, TResponse>)

Server-side handler for intercepting an incoming unary call.

public override Task<TResponse> UnaryServerHandler<TRequest, TResponse>(TRequest request, ServerCallContext context, UnaryServerMethod<TRequest, TResponse> continuation) where TRequest : class where TResponse : class

Parameters

request TRequest

The request value of the incoming invocation.

context ServerCallContext

An instance of ServerCallContext representing the context of the invocation.

continuation UnaryServerMethod<TRequest, TResponse>

A delegate that asynchronously proceeds with the invocation, calling the next interceptor in the chain, or the service request handler, in case of the last interceptor and return the response value of the RPC. The interceptor can choose to call it zero or more times at its discretion.

Returns

Task<TResponse>

A future representing the response value of the RPC. The interceptor can simply return the return value from the continuation intact, or an arbitrary response value as it sees fit.

Type Parameters

TRequest

Request message type for this method.

TResponse

Response message type for this method.