Body Limit | Echo Skip to content
Quickstart Guide Routing Guide Binding Guide
opennavigateescclose
`;function a(){const s=document.querySelector(".pagefind-ui");if(!s||s.querySelector(".echo-search-empty"))return!!s;const e=s.querySelector(".pagefind-ui__form");return e?(e.insertAdjacentHTML("afterend",i),!0):!1}if(!a()){const s=new MutationObserver(()=>{a()&&s.disconnect()});s.observe(document.body,{childList:!0,subtree:!0}),setTimeout(()=>{s.disconnect()},1e4)}

Body Limit

Body Limit middleware sets the maximum allowed size for a request body. If the size exceeds the configured limit, it sends a 413 Request Entity Too Large response.

The limit is enforced against both the Content-Length request header and the actual content read, which makes it resilient against spoofed headers. The limit is specified in bytes.

All core middleware lives in the middleware package:

import "github.com/labstack/echo/v5/middleware"
e := echo.New()
e.Use(middleware.BodyLimit(2_097_152)) // 2 MB
e := echo.New()
e.Use(middleware.BodyLimitWithConfig(middleware.BodyLimitConfig{}))
type BodyLimitConfig struct {
// Skipper defines a function to skip middleware.
Skipper Skipper
// LimitBytes is the maximum allowed size in bytes for a request body.
LimitBytes int64
}
// Effective defaults applied when fields are left unset (Limit is required).
BodyLimitConfig{
Skipper: DefaultSkipper,
}
© 2026 LabStack LLC. Released under the MIT License.