Body Limit
BodyLimit protects endpoints from unexpectedly large request bodies.
Quick start
Section titled “Quick start”app.Use(middleware.BodyLimit(10 * middleware.MB))Config
Section titled “Config”app.Use(middleware.BodyLimitWithConfig(middleware.BodyLimitConfig{ Limit: 10 * middleware.MB,}))Fields
Section titled “Fields”| Field | Meaning |
|---|---|
Skipper |
Skip the limit for selected requests |
Limit |
Required maximum size in bytes |
Size helpers
Section titled “Size helpers”Zinc exposes convenient constants:
middleware.Bmiddleware.KBmiddleware.MBmiddleware.GB
Failure behavior
Section titled “Failure behavior”When the body exceeds the configured limit, Zinc returns a *middleware.BodyLimitError.
That error includes:
LimitObservedSource
Source tells you whether the limit was exceeded from:
- the request’s
Content-Length - actual body reads
The error unwraps to zinc.ErrRequestEntityTooLarge.
