public static class ChannelExtensions : object
Provides extension methods to make it easy to register interceptors on Channel objects.
Namespace
Grpc.Core.InterceptorsAssembly
Grpc.Core.Api.dll
Methods
Intercept(ChannelBase, Func<Metadata, Metadata>)
public static CallInvoker Intercept(this ChannelBase channel, Func<Metadata, Metadata> interceptor)
Returns a CallInvoker instance that intercepts the invoker with the given interceptor.
Parameters | |
---|---|
Name | Description |
channel |
ChannelBase The channel to intercept. |
interceptor |
Func<Metadata, Metadata> An interceptor delegate that takes the request metadata to be sent with an outgoing call and returns a Metadata instance that will replace the existing invocation metadata. |
Returns | |
---|---|
Type | Description |
CallInvoker |
Multiple interceptors can be added on top of each other by building a chain like "channel.Intercept(c).Intercept(b).Intercept(a)". Note that in this case, the last interceptor added will be the first to take control.
Intercept(ChannelBase, Interceptor)
public static CallInvoker Intercept(this ChannelBase channel, Interceptor interceptor)
Returns a CallInvoker instance that intercepts the channel with the given interceptor.
Parameters | |
---|---|
Name | Description |
channel |
ChannelBase The channel to intercept. |
interceptor |
Interceptor The interceptor to intercept the channel with. |
Returns | |
---|---|
Type | Description |
CallInvoker |
Multiple interceptors can be added on top of each other by calling "channel.Intercept(a, b, c)". The order of invocation will be "a", "b", and then "c". Interceptors can be later added to an existing intercepted channel, effectively building a chain like "channel.Intercept(c).Intercept(b).Intercept(a)". Note that in this case, the last interceptor added will be the first to take control.
Intercept(ChannelBase, Interceptor[])
public static CallInvoker Intercept(this ChannelBase channel, params Interceptor[] interceptors)
Returns a CallInvoker instance that intercepts the channel with the given interceptors.
Parameters | |
---|---|
Name | Description |
channel |
ChannelBase The channel to intercept. |
interceptors |
Interceptor[] An array of interceptors to intercept the channel with. Control is passed to the interceptors in the order specified. |
Returns | |
---|---|
Type | Description |
CallInvoker |
Multiple interceptors can be added on top of each other by calling "channel.Intercept(a, b, c)". The order of invocation will be "a", "b", and then "c". Interceptors can be later added to an existing intercepted channel, effectively building a chain like "channel.Intercept(c).Intercept(b).Intercept(a)". Note that in this case, the last interceptor added will be the first to take control.