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
routerRouterThe router being configured.
compressionFormatCompressionFormatThe compression format for the compress operation.
compressionLevelCompressionLevelThe compression level for the compress operation.
Returns
- Router
The router being configured.
Examples
The following code adds the compressor middleware to the dispatch pipeline.
// Add the compressor middleware to the dispatch pipeline.
Router router = new Router()
.UseCompressor(CompressionFormat.Brotli)
.Map(new Chatbot());
// The default transport (QUIC) requires a server certificate. CreateServerAuthenticationOptions
// is a helper from examples/common/Program.Authentication.cs in the icerpc-csharp repo.
using var serverCertificate = X509CertificateLoader.LoadPkcs12FromFile(
"certs/server.p12",
password: null,
keyStorageFlags: X509KeyStorageFlags.Exportable);
await using var server = new Server(
router,
serverAuthenticationOptions: CreateServerAuthenticationOptions(serverCertificate));
server.Listen();
- See Also