livery_compress (livery v0.2.0)
View SourceResponse-compression middleware.
Negotiates the client's Accept-Encoding against the registered
livery_codec codecs and compresses eligible responses, setting
Content-Encoding and a cache-correct Vary: Accept-Encoding. gzip and
deflate are built in (OTP zlib); brotli/zstd become available when
their apps register a codec. Configure as a stack entry
{livery_compress, Config} where every key is optional:
codecs— list of codec modules in server-preference order (defaultlivery_codec:registered()); restricts/overrides the set.min_size— minimum{full, _}body size to compress (default 1024).types— compressibleContent-Typeprefixes (default text and the common structured types).
Negotiation
A coding is acceptable iff its Accept-Encoding q-value is > 0 (by
exact name or *; q=0 rejects). Among acceptable codings the SERVER
preference order wins; client q-weights are only an accept/reject
filter. With no acceptable coding the response is sent uncompressed
(identity); identity;q=0 is deliberately treated as identity, not a
406.
Scope
Only {full, _} (>= min_size) and {chunked, _} bodies with a
compressible Content-Type and no existing Content-Encoding are
eligible. SSE, file, empty, and upgrade bodies pass through unchanged.
Summary
Functions
Compress the downstream response when the client accepts a codec.
Functions
-spec call(livery_req:req(), livery_middleware:next(), map() | undefined) -> livery_resp:resp().
Compress the downstream response when the client accepts a codec.