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

httpjson

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package httpjson decodes strict JSON request bodies and writes JSON responses. Its functions are safe for concurrent use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(writer http.ResponseWriter, request *http.Request, target any) error

Decode requires Content-Type application/json, reads at most 64 KiB, rejects unknown fields and trailing data. Errors are plain and never repeat request text; callers wrap them as *auth.Error{Kind: auth.ErrInvalidRequest}.

func Write

func Write(writer http.ResponseWriter, status int, body any)

Write writes body as JSON with status, Content-Type application/json and Cache-Control no-store. A body that does not encode (an identity carrying an invalid auth.Permission from application code) is answered 500 internal instead, before anything was written.

Types

This section is empty.

Jump to

Keyboard shortcuts

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