Body Limit

Body limit middleware sets the maximum allowed size for a request body, if the
size exceeds the configured limit, it sends “413 - Request Entity Too Large”
response. The body limit is determined based on both Content-Length request
header and actual content read, which makes it super secure.

Limit can be specified as 4x or 4xB, where x is one of the multiple from K, M,
G, T or P.

Usage

  1. e := echo.New()
  2. e.Use(middleware.BodyLimit("2M"))

Custom Configuration

Usage

  1. e := echo.New()
  2. e.Use(middleware.BodyLimitWithConfig(middleware.BodyLimitConfig{}))

Configuration

  1. BodyLimitConfig struct {
  2. // Skipper defines a function to skip middleware.
  3. Skipper Skipper
  4. // Maximum allowed size for a request body, it can be specified
  5. // as `4x` or `4xB`, where x is one of the multiple from K, M, G, T or P.
  6. Limit string `json:"limit"`
  7. }

Default Configuration

  1. DefaultBodyLimitConfig = BodyLimitConfig{
  2. Skipper: DefaultSkipper,
  3. }