httpresponse

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 7 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 httpresponse owns common HTTP JSON response framing for API servers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteJSON

func WriteJSON(writer http.ResponseWriter, status int, value any)

WriteJSON writes the supplied status and standard JSON body. As at the existing HTTP boundaries, headers are committed before encoding and an encoding/write failure does not attempt a second response.

func WriteLocalizedRejection

func WriteLocalizedRejection(w http.ResponseWriter, r *http.Request, manager *localization.Manager, message localization.Message, status int, envelope RejectionEnvelope)

WriteLocalizedRejection writes an already-decided rejection. Validation and authentication remain with the calling middleware. JSONErrorText retains the auth boundary's JSON text passed through http.Error, including its newline, content type and nosniff behavior; it is not a normal JSON response.

func WritePropertyJSON

func WritePropertyJSON(writer http.ResponseWriter, status int, value any)

WritePropertyJSON binds the property-number domain before the shared HTTP response owner writes headers and standard JSON. It adds no response framing or error policy of its own.

Types

type RejectionEnvelope

type RejectionEnvelope uint8

RejectionEnvelope selects the existing text/plain rejection body format.

const (
	PlainText RejectionEnvelope = iota
	JSONErrorText
)

Jump to

Keyboard shortcuts

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