Skip to content

bzf/rocket_async_compression

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

[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)

use rocket_async_compression::Compression;

#[launch]
async fn main() {
    let server = rocket::build()
        .mount("/", routes![...]);
        
    if cfg!(debug_assertions) {
        server
    } else {
        server.attach(Compression::fairing())
    }
}

Contirbutors

About

Implements response compression with gzip and brotli via the `async-compression` crate

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Rust 100.0%