protocol

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeHTTPRequest

func DecodeHTTPRequest(input DecodeRequestInput) (*http.Request, error)

func DecodeHTTPResponse

func DecodeHTTPResponse(ctx context.Context, input DecodeResponseInput) *http.Response

func EncodeHTTPResponse

func EncodeHTTPResponse(
	ctx context.Context,
	events <-chan ir.Event,
	stream bool,
	encode func(<-chan ir.Event, http.ResponseWriter, bool) error,
) <-chan EncodedChunk

func EventsWithContext

func EventsWithContext(ctx context.Context, events <-chan ir.Event) <-chan ir.Event

func JoinUpstreamURL

func JoinUpstreamURL(baseURL, path string) (string, error)

func MergeHeaders

func MergeHeaders(base http.Header, overrides map[string][]string) map[string][]string

Types

type DecodeRequestInput

type DecodeRequestInput struct {
	Method  string
	Path    string
	Headers map[string][]string
	Body    []byte
}

type DecodeResponseInput

type DecodeResponseInput struct {
	Protocol   ir.Protocol
	StatusCode int
	Headers    map[string][]string
	Body       io.Reader
	Stream     bool
}

type EncodeRequestInput

type EncodeRequestInput struct {
	Request *ir.Request
	Target  Target
	Options convert.Options
}

type EncodeResponseInput

type EncodeResponseInput struct {
	Protocol ir.Protocol
	Events   <-chan ir.Event
	Stream   bool
}

type EncodedChunk

type EncodedChunk struct {
	Data []byte
	Err  error
}

type EncodedRequest

type EncodedRequest struct {
	Method  string
	Path    string
	Headers map[string][]string
	Body    []byte
}

type Endpoint

type Endpoint struct {
	Method   string
	Path     string
	Protocol ir.Protocol
}

type Handler

type Handler interface {
	DecodeRequest(DecodeRequestInput) (*ir.Request, error)
	EncodeRequest(EncodeRequestInput) (EncodedRequest, any, error)
	DecodeResponse(context.Context, DecodeResponseInput, any) (<-chan ir.Event, error)
	EncodeResponse(context.Context, EncodeResponseInput) (<-chan EncodedChunk, error)
	Endpoints() []Endpoint
}

type RouteKey

type RouteKey struct {
	Method string
	Path   string
}

type Target

type Target struct {
	Protocol     ir.Protocol
	BaseURL      string
	EndpointPath string
	APIKey       string
	Model        string
	Headers      map[string][]string
}

Directories

Path Synopsis
Package claude implements the Anthropic Claude Messages API protocol codec.
Package claude implements the Anthropic Claude Messages API protocol codec.
openai
chat
Package chat implements the OpenAI Chat Completions protocol codec.
Package chat implements the OpenAI Chat Completions protocol codec.
responses
Package responses implements the OpenAI Responses API protocol codec.
Package responses implements the OpenAI Responses API protocol codec.

Jump to

Keyboard shortcuts

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