#brotli #tide #middleware #gzip #compression

tide-compress

Outgoing compression middleware for the Tide server framework

19 releases (10 breaking)

0.11.0 Jan 16, 2023
0.10.6 Jul 31, 2022
0.10.3 Jun 29, 2022
0.9.0 Jan 29, 2021
0.4.0 Jul 19, 2020

#605 in HTTP server

Download history 120/week @ 2023-11-20 185/week @ 2023-11-27 322/week @ 2023-12-04 283/week @ 2023-12-11 17/week @ 2023-12-18 63/week @ 2023-12-25 16/week @ 2024-01-01 22/week @ 2024-01-08 98/week @ 2024-01-15 228/week @ 2024-01-22 23/week @ 2024-02-05 283/week @ 2024-02-12 154/week @ 2024-02-19 547/week @ 2024-02-26 221/week @ 2024-03-04

1,206 downloads per month

BlueOak-1.0.0

59KB
1K SLoC

tide-compress on crates.io Documentation (latest release)

tide-compress

Outgoing body compression middleware for the Tide server framework.

#[async_std::main]
async fn main() {
    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.
    • Also handles the "identity" encoding directive as per RFC 9110.
  • Accept-Encoding header 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.
    • The database can be regenerated in the crate's repository by running cargo run generate-database.
    • 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 poses build issues.

License

Licensed under the BlueOak Model License 1.0.0Contributions via DCO 1.1

Dependencies

~10–24MB
~367K SLoC