Documentation
¶
Overview ¶
Package bodylimit provides HTTP middleware that caps the size of request bodies. Bodies whose declared size exceeds the cap are rejected early with 413 Request Entity Too Large; bodies with unknown or understated lengths are limited when downstream handlers read them.
It is used both directly as a net/http middleware (the management API and the vMCP server) and via the runner middleware registry (the MCP proxies), so every inbound listener can bound the memory a single request may consume before it is buffered by handlers that call io.ReadAll.
Index ¶
Constants ¶
const ( // MiddlewareType is the type constant for the body limit middleware in the // runner middleware registry. MiddlewareType = "bodylimit" // DefaultMaxRequestBodySize is the generic request body fallback limit. DefaultMaxRequestBodySize = httplimit.DefaultMaxRequestBodySize )
Variables ¶
This section is empty.
Functions ¶
func CreateMiddleware ¶
func CreateMiddleware(config *types.MiddlewareConfig, runner types.MiddlewareRunner) error
CreateMiddleware is the types.MiddlewareFactory registered in the runner's GetSupportedMiddlewareFactories. It unmarshals MiddlewareParams, builds the handler via Middleware, and registers it with the runner.
func IsRequestTooLarge ¶
IsRequestTooLarge forwards the overflow check to the generic implementation.
Types ¶
type MiddlewareParams ¶
type MiddlewareParams struct {
// MaxBytes is the maximum request body size in bytes. Values <= 0 are
// treated as DefaultMaxRequestBodySize (zero never means "unlimited").
MaxBytes int64 `json:"max_bytes"`
}
MiddlewareParams holds the parameters for the body limit middleware factory.