httpjson

package
v0.1.0-rc.41 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package httpjson reads and writes size-limited JSON. callers handle authentication, media types, timeouts, closing bodies, and API errors. this package does not contain generated API or domain types.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTooLarge        = errors.New("JSON body exceeds limit")
	ErrTrailingContent = errors.New("JSON contains trailing content")
)

Functions

func Decode

func Decode(decoder *json.Decoder, destination any) error

Decode reads one JSON value and rejects unknown struct fields or trailing data. configure number handling and limit the input before calling it. the standard handling of null and duplicate object keys is unchanged.

func ReadAll

func ReadAll(reader io.Reader, limit int64) ([]byte, error)

ReadAll reads up to limit bytes and returns ErrTooLarge when more data exists. it does not close the reader. I/O failures are returned unchanged.

func Write

func Write(response http.ResponseWriter, status int, value any)

Write sends an application/json response. if encoding fails after writing has started, it aborts the response instead of adding a second error body.

func WriteProblem

func WriteProblem(response http.ResponseWriter, status int, value any)

WriteProblem sends an application/problem+json response.

Types

This section is empty.

Jump to

Keyboard shortcuts

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