httpx

package
v0.40.7 Latest Latest
Warning

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

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

Documentation

Overview

Package httpx contains tiny cross-handler helpers for JSON error envelopes and status mapping. Keeping it in its own package prevents import cycles between core and mode packages.

Index

Constants

View Source
const APIPrefixHeader = "X-SpeechKit-API-Prefix"

APIPrefixHeader carries the external API mount prefix after an internal route alias rewrites /api/v1/* to the stable /v1/* handler tree.

Variables

This section is empty.

Functions

func WriteError

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

WriteError emits a standard JSON error envelope and sets the status code. It never panics; encoding failures degrade to an empty body.

func WriteErrorWithDetails

func WriteErrorWithDetails(w http.ResponseWriter, status int, code, message string, details map[string]any)

WriteErrorWithDetails is the same as WriteError but attaches a details map.

func WriteModeDisabled added in v0.40.1

func WriteModeDisabled(w http.ResponseWriter, mode string)

WriteModeDisabled emits the canonical disabled-mode envelope used by the Server-Target when an endpoint exists but its owning mode is configured off.

Types

type ErrorBody

type ErrorBody struct {
	Error ErrorDetail `json:"error"`
}

ErrorBody is the wire shape of every 4xx/5xx response from the SpeechKit server adapter. It is deliberately minimal so consumers (kombify-AI, OSS integrators) can pin to a stable contract.

type ErrorDetail

type ErrorDetail struct {
	Code    string         `json:"code"`
	Message string         `json:"message"`
	Details map[string]any `json:"details,omitempty"`
}

ErrorDetail carries the machine-readable code and the human-friendly message. Additional context belongs in Details (a free-form map).

Jump to

Keyboard shortcuts

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