Skip to content

Fishrock123/tide-compress

Repository files navigation

tide-compress

Outgoing compression middleware for the Tide server framework.

#[async_std::main]
async fn main() -> tide::Result {
    let mut app = tide::new();
    app.with(tide_compress::CompressMiddleware::new());
}

Features

  • Support for Brotli, Gzip, and Deflate encodings, compile-time configurable through cargo feature flags.
    • Prioritizes Brotli if available.
    • Only pulls in the necessary dependencies for the desired configuration.
    • Defaults to Brotli & Gzip.
  • Accept-Encoding checking including priority.
  • Minimum body size threshold (Default: 1024 bytes, configurable).
  • Does not compress responses with a Cache-Control: no-transform header.
  • Sets the Vary header.
  • Checks the Content-Type header (MIME).
    • Checks against jshttp's comprehensive database, which is compiled to a perfect hash function at build time.
    • If not in the database, checks against a regular expression.
      • Default: ^text/|\+(?:json|text|xml)$ (case insensitive).
      • Fully override-able to any custom Regex, with None as an option.
    • Functionality can be excluded in crate features if the regex crate or codegen poses build issues.

Note

This crate, in its current set up with the db-check feature enabled (which is by default), pulls down a json MIME database from the network at build time.

License

Licensed under the BlueOak Model License 1.0.0Contributions via DCO 1.1

About

Outgoing compression middleware for the Tide web framework.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •