Skip to main content

Decompress

Decompress unwraps request bodies sent with Content-Encoding: gzip.

app.Use(middleware.Decompress())

Handlers can then read the body normally.

app.Post("/ingest", func(c *zinc.Context) error {
var input Event
if err := c.Bind().JSON(&input); err != nil {
return err
}
return c.NoContent()
})

Unsupported content encodings return 415 Unsupported Media Type. Invalid gzip bodies return 400 Bad Request.

Use MaxDecompressedSize when compressed uploads should be capped after decompression.

app.Use(middleware.DecompressWithConfig(middleware.DecompressConfig{
MaxDecompressedSize: 4 << 20,
}))

Requests that expand past the limit return 413 Payload Too Large.