maxbody

package
v2.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2026 License: Apache-2.0 Imports: 2 Imported by: 2

Documentation

Overview

Package maxbody provides stable request-body size limiting middleware.

Use New with an explicit byte limit before handlers read request bodies, especially upload, webhook, and JSON write endpoints. Oversized requests fail at the edge instead of allowing unbounded memory or disk pressure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware

type Middleware struct {
	MaxBytes int64
}

Middleware enforces a maximum request body size.

func New

func New(opts Options) (*Middleware, error)

New constructs a max-body middleware with the given limit.

func (*Middleware) Handler

func (m *Middleware) Handler(next http.Handler) http.Handler

Handler wraps the next handler with body size limits.

func (*Middleware) Middleware

func (m *Middleware) Middleware() func(http.Handler) http.Handler

Middleware implements ports.Middleware via Handler adapter.

type Options

type Options struct {
	MaxBytes int64
}

Options configures the max-body middleware.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL