httpx

package
v0.73.4 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 5 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 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 (service-to-service callers, 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).

type TrustedProxies added in v0.42.0

type TrustedProxies struct {
	// contains filtered or unexported fields
}

TrustedProxies decides whether request Forwarded/X-Forwarded-* headers may influence security-sensitive behavior.

func NewTrustedProxies added in v0.42.0

func NewTrustedProxies(raw []string) (TrustedProxies, error)

func (TrustedProxies) RequestIsHTTPS added in v0.42.0

func (t TrustedProxies) RequestIsHTTPS(r *http.Request) bool

RequestIsHTTPS reports whether the request is HTTPS directly or through a trusted proxy that supplied X-Forwarded-Proto=https.

func (TrustedProxies) TrustsRequest added in v0.42.0

func (t TrustedProxies) TrustsRequest(r *http.Request) bool

Jump to

Keyboard shortcuts

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