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

body

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package body provides HTTP request body parsing with Content-Type handling.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedMediaType = errors.New("unsupported media type")
	ErrBodyTooLarge         = errors.New("request body too large")
)

Error types

Functions

This section is empty.

Types

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser parses HTTP request bodies based on Content-Type.

func NewParser

func NewParser(accepts []config.AcceptType) *Parser

NewParser creates a new Parser with the given accepted types.

func (*Parser) Parse

func (p *Parser) Parse(r *http.Request) (map[string]any, error)

Parse parses the request body based on Content-Type. Returns ErrUnsupportedMediaType if Content-Type is not in accepts. Returns errBadRequest if body parsing fails. Returns ErrBodyTooLarge if body exceeds maxBodySize.

Jump to

Keyboard shortcuts

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