Compression Module for Pingora
This crate helps configure Pingora’s built-in compression mechanism. It provides two configuration options:
compression_level(--compression-levelas command-line option): If present, will enable dynamic downstream compression and use the specified compression level (same level for all compression algorithms, see Pingora issue #228).decompress_upstream(--decompress-upstreamas command-line flag): Iftrue, decompression of upstream responses will be enabled.
Code example
You will usually want to merge Pingora’s command-line options and configuration settings with the ones provided by this crate:
use ;
use ;
use Server;
use ;
use StructOpt;
let opt = from_args;
let mut conf = opt
.server
.conf
.as_ref
.and_then
.unwrap_or_else;
conf.compression.merge_with_opt;
let mut server = new_with_opt_and_conf;
server.bootstrap;
let compression_handler: CompressionHandler = conf.compression.try_into.unwrap;
You can then use that handler in your server implementation:
use async_trait;
use CompressionHandler;
use RequestFilter;
use Error;
use HttpPeer;
use ;
For complete and more realistic code, see single-static-root example in the repository.