Struct iron_pack::CompressionMiddleware [] [src]

pub struct CompressionMiddleware;

Compression Middleware

Currently either compresses using brotli, gzip or deflate algorithms. The algorithm is chosen by evaluating the AcceptEncoding header sent by the client.

Example

extern crate iron;
extern crate iron_pack;

use iron::prelude::*;
use iron_pack::CompressionMiddleware;

fn a_lot_of_batman(_: &mut Request) -> IronResult<Response> {
    let nana = "Na".repeat(5000);
    Ok(Response::with((iron::status::Ok, format!("{}, Batman!", nana))))
}

fn main() {
    let mut chain = Chain::new(a_lot_of_batman);
    chain.link_after(CompressionMiddleware);
    Iron::new(chain).http("localhost:3000").unwrap();
}

Trait Implementations

impl AfterMiddleware for CompressionMiddleware
[src]

[src]

Implementation of the compression middleware

[src]

Respond to an error thrown by previous AfterMiddleware, the Handler, or a BeforeMiddleware. Read more