Documentation
¶
Overview ¶
Package api provides shared voice gateway API infrastructure.
Index ¶
- func WithSessionProtocol(ctx context.Context, p SessionProtocol) context.Context
- func WriteError(w http.ResponseWriter, status int, code ErrorCode, message string)
- func WriteJSON(w http.ResponseWriter, status int, v any)
- type EmptyReq
- type Error
- type ErrorCode
- type ErrorDetails
- type ErrorResponse
- type ProtocolVersion
- type SessionProtocol
- type Validatable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithSessionProtocol ¶
func WithSessionProtocol(ctx context.Context, p SessionProtocol) context.Context
WithSessionProtocol binds HTTP route selection to the session lifetime.
func WriteError ¶
func WriteError(w http.ResponseWriter, status int, code ErrorCode, message string)
WriteError writes a JSON error response with the given HTTP status and code.
Types ¶
type Error ¶
type Error struct {
// Status is the HTTP status code.
Status int
// Code is the machine-readable error code.
Code ErrorCode
// Message is the client-facing error message.
Message string
// Details holds optional unstructured diagnostics.
Details map[string]any
// Cause is the optional underlying error.
Cause error
}
Error is a concrete error type with status code, error code, optional details, and optional wrapped error.
type ErrorDetails ¶
type ErrorDetails struct {
// Code is the machine-readable error code.
Code ErrorCode `json:"code"`
// Message is the human-readable error message.
Message string `json:"message"`
}
ErrorDetails holds the code and message within an error response.
type ErrorResponse ¶
type ErrorResponse struct {
// Error contains the machine-readable code and human-readable message.
Error ErrorDetails `json:"error"`
// Details contains optional endpoint-specific structured error context.
Details map[string]any `json:"details,omitempty"`
}
ErrorResponse is the JSON envelope for error responses.
type ProtocolVersion ¶
type ProtocolVersion uint8
ProtocolVersion identifies a published voice gateway wire contract.
const ( // ProtocolV2 is the current gateway contract and the default for direct bridge calls. ProtocolV2 ProtocolVersion = iota // ProtocolV1 is the gateway contract published with Go Mode v0.3.0. ProtocolV1 )
func (ProtocolVersion) AcceptsTextSubprotocol ¶
func (v ProtocolVersion) AcceptsTextSubprotocol(headers []string) bool
AcceptsTextSubprotocol permits native clients to omit negotiation. Otherwise the route-selected protocol must appear among the offered alternatives.
func (ProtocolVersion) String ¶
func (v ProtocolVersion) String() string
String returns the route version name.
func (ProtocolVersion) TextSubprotocol ¶
func (v ProtocolVersion) TextSubprotocol() string
TextSubprotocol returns the WebSocket subprotocol for this wire version.
type SessionProtocol ¶
type SessionProtocol struct {
Version ProtocolVersion
DefaultVoice string
}
SessionProtocol binds a session to its selected wire contract. DefaultVoice is the explicit gateway-owned v1 voice advertised for the selected choice; an empty value means that choice advertises no voice catalog.
func SessionProtocolFromContext ¶
func SessionProtocolFromContext(ctx context.Context) SessionProtocol
SessionProtocolFromContext returns the selected wire contract. Direct bridge callers that do not select a version use v2.
type Validatable ¶
type Validatable interface {
Validate() error
}
Validatable is implemented by request types that can validate their fields.