body

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const MaxBodySize = 10 * 1024 * 1024

MaxBodySize is the maximum allowed request body size (10MB).

Variables

View Source
var (
	ErrUnsupportedMediaType = errors.New("unsupported media type")
	ErrBadRequest           = errors.New("bad request")
	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