Help us shape the future of Go! Take the 2026 Go Developer Survey

extractors

package
v0.69.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package extractors decodes and validates request input: Body decodes into a typed struct and runs its Validate method when it has one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Body

func Body[T any](w http.ResponseWriter, r *http.Request) (T, error)

Body decodes a JSON request body into T, capped at 1 MiB with unknown fields rejected, then validates it. A body over the cap returns the *http.MaxBytesError itself, which mid.Errors renders as 413.

func Files

func Files(w http.ResponseWriter, r *http.Request, field string, maxBytes int64, maxFiles int) ([]*multipart.FileHeader, func(), error)

Files leaves at most 1 MiB in memory; callers remove the form's temporary files after closing the readers. Authentication must precede extraction.

Types

type Validator

type Validator interface {
	Validate() error
}

Validator is the optional contract a request struct implements to be validated after decoding.

Jump to

Keyboard shortcuts

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