Expand description
Response compression (gzip / brotli). Behind the compression feature.
Build a CompressionLayer and hand it to crate::Server::with_compression.
For each response Actus picks an encoding from the request’s
Accept-Encoding (preferring brotli when offered), and — if the body is a
buffered, compressible type above a size threshold — compresses it,
setting Content-Encoding and appending Vary: Accept-Encoding.
Scope: this compresses buffered response bodies (the common case — JSON
API responses, reply::bytes). Streamed responses (reply!(stream: …))
and error bodies pass through uncompressed for now.
ⓘ
use actus::prelude::*;
Server::new(router).with_compression(CompressionLayer::new()); // defaults
Server::new(router).with_compression(CompressionLayer::new().min_size(256).prefer_gzip());Structs§
- Compression
Layer - A response-compression policy. See the module docs.