wire

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package wire defines the JSON envelope protocol exchanged with the CLIProxyAPI host. Every plugin method returns an {ok, result, error} envelope; this package centralizes its encoding so the CGO bridge and all domain handlers agree on the wire format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(code, message string) []byte

Error returns an error envelope carrying a code and message.

func ErrorStatus

func ErrorStatus(code, message string, status int) []byte

ErrorStatus returns an error envelope carrying an HTTP status the host can use to drive retry/refresh scheduling.

func OK

func OK(v any) ([]byte, error)

OK marshals v as the result payload of a successful envelope.

Types

type Envelope

type Envelope struct {
	OK     bool            `json:"ok"`
	Result json.RawMessage `json:"result,omitempty"`
	Error  *EnvelopeError  `json:"error,omitempty"`
}

Envelope is the JSON wire format exchanged with the host: {ok, result, error}.

type EnvelopeError

type EnvelopeError struct {
	Code       string `json:"code"`
	Message    string `json:"message"`
	HTTPStatus int    `json:"http_status,omitempty"`
}

EnvelopeError carries a plugin error plus an optional HTTP status the host can use to drive retry/refresh scheduling.

Jump to

Keyboard shortcuts

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