Rocket Async Compression

Open in Gitpod

This library provides response compression in both gzip and brotli formats for the Rocket using the async-compression library.

It currently supports usage with Rocket 0.5.0-rc.1. If you want to use a different version, you'll have to fork this library and change Cargo.toml.

I'd love to get this merged into Rocket itself eventually since I think it would be a very useful addition that I myself can barely live without in a webserver.

Installation

Add this to Cargo.toml:

toml [dependencies] rocket = "0.5.0-rc.1" rocket_async_compression = "0.1.0"

Usage

The following example will enable compression on releases cause localhost isn't on a remote network (usually) ```rs use rocketasynccompression::Compression;

[launch]

async fn main() { let server = rocket::build() .mount("/", routes![...]);

if cfg!(debug_assertions) {
    server
} else {
    server.attach(Compression::fairing())
}

} ```

Contirbutors