httpjson

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package httpjson writes the server's uniform JSON responses and error envelopes. It marshals into a buffer BEFORE writing the status line, so an encoding failure becomes a clean 500 rather than a committed 200 with a truncated body. Every HTTP surface (native, Hrana, auth middleware, admin) routes its responses through here so the wire shape is defined once.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(w http.ResponseWriter, status int, msg string)

Error writes the standard {"error":{"message":…}} envelope with the given status.

func Write

func Write(w http.ResponseWriter, status int, v any)

Write marshals v and writes it with the given status. A marshal failure is reported as a 500 with a fixed error envelope.

Types

This section is empty.

Jump to

Keyboard shortcuts

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