Class RequestContextPipelineExtensions
- Namespace
- IceRpc
- Assembly
- IceRpc.RequestContext.dll
Provides an extension method for Pipeline to add the request context interceptor.
public static class RequestContextPipelineExtensions
- Inheritance
-
RequestContextPipelineExtensions
- Inherited Members
Methods
UseRequestContext(Pipeline)
Adds a RequestContextInterceptor to this pipeline.
public static Pipeline UseRequestContext(this Pipeline pipeline)
Parameters
pipeline
PipelineThe pipeline being configured.
Returns
- Pipeline
The pipeline being configured.
Examples
The following code adds the request context interceptor to the invocation pipeline.
// Create a client connection.
await using var connection = new ClientConnection(new Uri("icerpc://localhost"));
// Add the request context interceptor to the invocation pipeline.
Pipeline pipeline = new Pipeline()
.UseRequestContext()
.Into(connection);
var greeterProxy = new GreeterProxy(pipeline);
// Create a feature collection holding an IRequestContextFeature.
IFeatureCollection features = new FeatureCollection().With<IRequestContextFeature>(
new RequestContextFeature
{
["UserId"] = Environment.UserName.ToLowerInvariant(),
["MachineName"] = Environment.MachineName
});
// The request context interceptor encodes the request context feature into the request context field.
string greeting = await greeterProxy.GreetAsync(Environment.UserName, features);
- See Also