PlugCaisson

An Elixir Plug.Parsers body reader that supports compressed payloads. Supports gzip, brotli, and more.

A caisson is an geoengineering structure used to work on foundations of bridges and piers. Due to pressurised environment in the caisson (required to keep water out of it (as it has no bottom) people can get decompression sickness, also known as caisson disease.

Installation

Add :plug_caisson to dependencies in mix.exs:

def deps do
  [
    {:plug_caisson, "~> 0.2.0"},
    # optional, for brotli support
    {:brotli, "~> 0.3.2"},
    # optional, for zstd support
    {:ezstd, "~> 1.0"},
  ]
end

And then add {PlugCaisson, :read_body, []} as a :body_reader to your Plug.Parsers:

plug Plug.Parsers,
  parsers: [:urlencoded, :json],
  body_reader: {PlugCaisson, :read_body, []},
  length: 8_000_000

All options passed to the plug are forwarded to Plug.Conn.read_body/2.

Supported algorithms

[^1]:

Do not support streaming decoding yet, because of lack support for such
flow upstream, see [ezstd#11](https://github.com/silviucpp/ezstd/issues/11)