Skip to main content

Module compress

Module compress 

Source
Expand description

Built-in gzip/brotli response compression. with_thread_local borrows a per-thread encoder so a handler can compress a body without per-request allocation; encode returns the compressed bytes. This is sark’s standard compression path — response bodies are never hand-rolled.

use sark_core::http::compress::Gzip;
let body: &[u8] = b"hello";
let zipped = Gzip::with_thread_local(|gz| gz.encode(body).to_vec());

Structs§

Brotli
Brotli response compression. br typically yields a smaller body than gzip for text/JSON.
Gzip