httpjson

package
v0.1.0-rc.43 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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