bodylimit

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package bodylimit provides express middleware that rejects requests whose body exceeds a configured size, guarding handlers against oversized uploads.

Index

Constants

View Source
const DefaultMaxBytes int64 = 1 << 20 // 1 MiB

DefaultMaxBytes is the limit applied when New is called with no options.

Variables

This section is empty.

Functions

func New

func New(opts ...Options) express.Handler

New returns middleware enforcing a maximum request body size. If the declared Content-Length exceeds the limit the request is rejected immediately with 413 Payload Too Large. Otherwise req.Raw.Body is wrapped in an http.MaxBytesReader so that a body larger than the limit fails when read.

Types

type Options

type Options struct {
	// MaxBytes is the maximum allowed request body size in bytes. A value of
	// 0 or less disables the limit.
	MaxBytes int64
}

Options configures the bodylimit middleware.

Jump to

Keyboard shortcuts

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