httpclient

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsMessagePackResponse added in v0.3.0

func IsMessagePackResponse(resp *http.Response) bool

IsMessagePackResponse reports whether a response advertises the entity MessagePack media type. It is shared with the stream iterator.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps an http.Client with helpers for Onyx API communication.

func New

func New(baseURL string, httpClient *http.Client, opts Options) *Client

New constructs a Client.

func (*Client) DoEntity added in v0.3.0

func (c *Client) DoEntity(ctx context.Context, method, path string, reqBody any, respBody any, wireFormat string) error

DoEntity executes an entity request in the configured wire format. A server may answer a MessagePack request with JSON; the actual response Content-Type selects the decoder.

func (*Client) DoEntityStream added in v0.3.0

func (c *Client) DoEntityStream(ctx context.Context, method, path string, reqBody any, wireFormat string) (*http.Response, error)

DoEntityStream starts an entity stream in the configured wire format.

func (*Client) DoJSON

func (c *Client) DoJSON(ctx context.Context, method, path string, reqBody any, respBody any) error

DoJSON executes an HTTP request and decodes the JSON response.

func (*Client) DoStream

func (c *Client) DoStream(ctx context.Context, method, path string, reqBody any) (*http.Response, error)

DoStream executes an HTTP request and returns the response for streaming consumption.

func (*Client) LogResponses added in v0.2.0

func (c *Client) LogResponses() bool

LogResponses reports whether response logging is enabled.

func (*Client) Logger added in v0.2.0

func (c *Client) Logger() *log.Logger

Logger returns the configured logger (never nil).

type Options

type Options struct {
	Logger       *log.Logger
	LogRequests  bool
	LogResponses bool
	Signer       Signer
}

Options controls the behavior of the HTTP client wrapper.

type Signer

type Signer struct {
	APIKey    string
	APISecret string
}

Signer applies API authentication headers.

func (Signer) Sign

func (s Signer) Sign(req *http.Request, body []byte) error

Sign mutates the request in place by adding authentication headers.

Jump to

Keyboard shortcuts

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