Body Limit
Request body size limiter. Rejects requests with bodies larger than the configured limit before they reach your handler.
Usage
r.Use(middleware.BodyLimit("1M"))
How It Works
- Wraps
c.Request.Bodywith ahttp.MaxBytesReader - If the body exceeds the limit, the reader returns an error on read
- The middleware returns
413 Request Entity Too Large
Supported Units
B- bytesK- kilobytesM- megabytesG- gigabytes
Examples: "500B", "2K", "10M", "1G"