api

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: AGPL-3.0 Imports: 5 Imported by: 2 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 api provides shared voice gateway API infrastructure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteError

func WriteError(log *slog.Logger, w http.ResponseWriter, r *http.Request, e *Error)

WriteError writes e as the JSON error response to r with its HTTP status and the request ID that apidto.RequestIDHandler set on r. The body omits the cause. Under the same rid, it logs a 5xx e as an error and another e with a cause as a warning, both with the cause.

func WriteJSON

func WriteJSON(log *slog.Logger, w http.ResponseWriter, status int, v any)

WriteJSON writes v as a JSON response with the given HTTP status. log receives encoding failures.

Types

type Error

type Error = apidto.Error[ErrorCode]

Error is a voice gateway API error; WriteError writes it.

type ErrorCode

type ErrorCode string

ErrorCode is a machine-readable error identifier.

const (
	CodeBadRequest    ErrorCode = "BAD_REQUEST"
	CodeUnauthorized  ErrorCode = "UNAUTHORIZED"
	CodeForbidden     ErrorCode = "FORBIDDEN"
	CodeNotFound      ErrorCode = "NOT_FOUND"
	CodeConflict      ErrorCode = "CONFLICT"
	CodeInternalError ErrorCode = "INTERNAL_ERROR"

	CodeVoiceBridgeUnavailable ErrorCode = "VOICE_BRIDGE_UNAVAILABLE"
	CodeVoiceOfferFailed       ErrorCode = "VOICE_OFFER_FAILED"
	// CodeRateLimited answers 429; its Retry-After header, when present, says when to retry.
	CodeRateLimited ErrorCode = "RATE_LIMITED"
)

Standard error codes.

type ErrorResponse

type ErrorResponse = apidto.ErrorResponse[ErrorCode]

ErrorResponse is the JSON body of a voice gateway error response.

type ProtocolVersion

type ProtocolVersion uint8

ProtocolVersion identifies a published voice gateway wire contract.

const ProtocolV2 ProtocolVersion = 0

ProtocolV2 is the current gateway contract.

func ProtocolVersions added in v0.5.0

func ProtocolVersions() []ProtocolVersion

ProtocolVersions returns the published gateway contracts, oldest first. Hosts mount one route prefix per entry, so retiring a version needs no host edit.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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