httputil

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteInternalError

func WriteInternalError(w http.ResponseWriter, err error, logMsg string, attrs ...any)

WriteInternalError logs the error with logMsg and attrs, then writes 500 and {"error": "internal error"}. logMsg is the slog message (e.g. "auth handler error", "portal handler error").

func WriteJSON

func WriteJSON(w http.ResponseWriter, status int, data any)

WriteJSON sets Content-Type application/json, writes status code, and encodes data as JSON.

func WriteJSONError

func WriteJSONError(w http.ResponseWriter, status int, message string)

WriteJSONError sets Content-Type application/json, writes status code, and a body {"error": "<message>"}.

func WriteQuotaExceeded

func WriteQuotaExceeded(w http.ResponseWriter, reason string)

WriteQuotaExceeded writes HTTP 429 with JSON body {"error": reason}.

Types

This section is empty.

Jump to

Keyboard shortcuts

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