pub struct CompressMiddleware;Expand description
The middleware that answers with the content coding the client accepts.
§Examples
use hyperlane::Server;
use hyperlane_plugin_negotiate::CompressMiddleware;
let mut server: Server = Server::default();
server.response_middleware::<CompressMiddleware>();Implementations§
Source§impl CompressMiddleware
Inherent implementation of CompressMiddleware.
impl CompressMiddleware
Inherent implementation of CompressMiddleware.
Sourcepub fn init(config: CompressConfig) -> Result<(), String>
pub fn init(config: CompressConfig) -> Result<(), String>
Installs the configuration the middleware works from.
The configuration is process wide, because the framework registers a middleware by its type and a hook is built per request rather than per server, so a server cannot carry a configuration of its own.
§Arguments
CompressConfig- The configuration to work from.
§Returns
Result<(), String>- Nothing, or the reason the configuration was refused.
Sourcepub fn get() -> Option<&'static CompressConfig>
pub fn get() -> Option<&'static CompressConfig>
Returns the installed global CompressConfig, when CompressMiddleware::init was called.
§Returns
Option<&'static CompressConfig>- Installed configuration, orNone.
Trait Implementations§
Source§impl Clone for CompressMiddleware
impl Clone for CompressMiddleware
impl Copy for CompressMiddleware
Source§impl Debug for CompressMiddleware
impl Debug for CompressMiddleware
Source§impl Default for CompressMiddleware
impl Default for CompressMiddleware
Source§impl ServerHook for CompressMiddleware
Implements ServerHook for CompressMiddleware.
impl ServerHook for CompressMiddleware
Implements ServerHook for CompressMiddleware.
Source§async fn handle(self, _: &mut Stream, ctx: &mut Context) -> Status
async fn handle(self, _: &mut Stream, ctx: &mut Context) -> Status
Negotiates the content coding of the response the pipeline is about to send.
The middleware never writes to the stream: it only declares the coding on the response, and the response builder applies the coding when the sender serializes the response. A response that already declares a coding is left alone, because coding a coded body produces bytes no client can read.
§Arguments
Self- The middleware.&mut Stream- The stream the request arrived on.&mut Context- The context of the request.
§Returns
Status- Whether the pipeline continues.