Documentation
¶
Overview ¶
Package apierr is the shared HTTP response envelope: the Tinybird-compatible error shape (ADR 0012) and JSON write helpers. Centralized so every handler — core routes and the /v0/sql, /v0/metrics, etc. add-ons — emits an identical structure and status mapping.
Index ¶
- Constants
- func EncodeJSON(w http.ResponseWriter, status int, v any)
- func WriteError(w http.ResponseWriter, status int, msg string)
- func WriteErrorWithCode(w http.ResponseWriter, status, dbCode int, msg string)
- func WriteJSON(w http.ResponseWriter, status int, raw []byte)
- func WriteRaw(w http.ResponseWriter, status int, contentType string, raw []byte)
Constants ¶
View Source
const DBExceptionHeader = "X-DB-Exception-Code"
DBExceptionHeader passes the ClickHouse exception code through to the client (ADR 0012). Set it from a clickhouse.CHError when one is available.
Variables ¶
This section is empty.
Functions ¶
func EncodeJSON ¶
func EncodeJSON(w http.ResponseWriter, status int, v any)
EncodeJSON marshals v and sends it with the given status.
func WriteError ¶
func WriteError(w http.ResponseWriter, status int, msg string)
WriteError sends {"error": msg} with the given status (ADR 0012).
func WriteErrorWithCode ¶
func WriteErrorWithCode(w http.ResponseWriter, status, dbCode int, msg string)
WriteErrorWithCode is WriteError plus the X-DB-Exception-Code header.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.