Class CompressorRouterExtensions
- Namespace
- IceRpc
- Assembly
- IceRpc.Compressor.dll
Provides an extension method for Router to add the compressor middleware.
public static class CompressorRouterExtensions
- Inheritance
-
CompressorRouterExtensions
- Inherited Members
Methods
UseCompressor(Router, CompressionFormat, CompressionLevel)
Adds a CompressorMiddleware to this router.
public static Router UseCompressor(this Router router, CompressionFormat compressionFormat, CompressionLevel compressionLevel = CompressionLevel.Fastest)
Parameters
router
RouterThe router being configured.
compressionFormat
CompressionFormatThe compression format for the compress operation.
compressionLevel
CompressionLevelThe compression level for the compress operation.
Returns
- Router
The router being configured.
Examples
The following code adds the compressor middleware to the dispatch pipeline.
// Create a connection.
await using var connection = new ClientConnection(new Uri("icerpc://localhost"));
// Add the compressor middleware to the dispatch pipeline.
Router router = new Router()
.UseCompressor(CompressionFormat.Brotli)
.Map<IGreeterService>(new Chatbot());
await using var server = new Server(router);
server.Listen();
- See Also