api

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package api provides shared voice gateway API infrastructure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmptyReq

type EmptyReq struct{}

EmptyReq is used for endpoints that take no request body.

func (EmptyReq) Validate

func (EmptyReq) Validate() error

Validate is a no-op for empty requests.

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.

func (*Error) Error

func (e *Error) Error() string

Error returns the error message, including any wrapped error.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the wrapped error.

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"
)

Standard error codes.

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 Validatable

type Validatable interface {
	Validate() error
}

Validatable is implemented by request types that can validate their fields.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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