client

package
v0.17.3 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Code generated by apic; DO NOT EDIT.

Code generated by apic; DO NOT EDIT.

Code generated by apic; DO NOT EDIT.

Code generated by apic; DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingAPIKeySecret indicates api_key auth was required but no secret was configured.
	ErrMissingAPIKeySecret = errors.New("missing API key secret")
	// ErrMissingBearerToken indicates jwt auth was required but no bearer token was configured.
	ErrMissingBearerToken = errors.New("missing bearer token")
)

Functions

func WithCorrelationID added in v0.15.1

func WithCorrelationID(ctx context.Context, id string) context.Context

WithCorrelationID attaches an end-to-end correlation id to ctx. The client sends it as the defaultCorrelationHeader ("X-Correlation-ID") header on every REST, GraphQL, and WebSocket call. When ctx carries none (or an unusable value), the client generates one per call.

func WithTraceParent added in v0.15.1

func WithTraceParent(ctx context.Context, traceparent string) context.Context

WithTraceParent attaches a W3C traceparent to ctx for explicit trace-context passthrough. When well-formed ("00-<32-hex trace-id>-<16-hex span-id>-<2-hex flags>") the client forwards it verbatim as the "traceparent" header on every REST, GraphQL, and WebSocket call. The client links no OpenTelemetry runtime, so it never derives a traceparent from an ambient span — pass it explicitly.

Types

type BinarySocket

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

BinarySocket wraps a binary WebSocket endpoint.

func (*BinarySocket) Close

func (s *BinarySocket) Close() error

Close closes the underlying websocket.

func (*BinarySocket) Receive

func (s *BinarySocket) Receive() ([]byte, error)

Receive blocks until the next binary payload arrives.

func (*BinarySocket) Send

func (s *BinarySocket) Send(payload []byte) error

Send writes one binary payload.

type Client

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

Client is the generated Go client for REST, GraphQL, and WebSocket APIs.

func New

func New(baseURL string, opts ...ClientOption) (*Client, error)

New constructs a generated client from an absolute base URL.

func (*Client) ConnectBinary

func (c *Client) ConnectBinary(ctx context.Context) (*BinarySocket, error)

ConnectBinary opens /ws/binary.

func (*Client) ConnectFeed

func (c *Client) ConnectFeed(ctx context.Context) (*JSONSocket[types.FeedMsg], error)

ConnectFeed opens /ws/feed.

func (*Client) Create

Create performs POST /v1/posts/create.

func (*Client) GraphQLCreatePost

func (c *Client) GraphQLCreatePost(ctx context.Context, req *types.PostCreateReq) (*types.PostCreateResp, error)

GraphQLCreatePost performs the createPost GraphQL mutation.

func (*Client) GraphQLRegisterUser

func (c *Client) GraphQLRegisterUser(ctx context.Context, req *types.RegisterReq) (*types.RegisterResp, error)

GraphQLRegisterUser performs the registerUser GraphQL mutation.

func (*Client) GraphQLSearchPosts

func (c *Client) GraphQLSearchPosts(ctx context.Context, req *types.PostSearchReq) (*types.PostSearchResp, error)

GraphQLSearchPosts performs the searchPosts GraphQL mutation.

func (*Client) GraphQLSubscribeBinaryStream

func (c *Client) GraphQLSubscribeBinaryStream(ctx context.Context) (*GraphQLSubscription[types.BinaryMsg], error)

GraphQLSubscribeBinaryStream opens a typed GraphQL subscription stream.

func (*Client) GraphQLSubscribeFeedEvents

func (c *Client) GraphQLSubscribeFeedEvents(ctx context.Context) (*GraphQLSubscription[types.FeedMsg], error)

GraphQLSubscribeFeedEvents opens a typed GraphQL subscription stream.

func (*Client) GraphQLUpdateUser

func (c *Client) GraphQLUpdateUser(ctx context.Context, req *types.UserUpdateReq) (*types.UserUpdateResp, error)

GraphQLUpdateUser performs the updateUser GraphQL mutation.

func (*Client) Register

func (c *Client) Register(ctx context.Context, req *types.RegisterReq) (*types.RegisterResp, error)

Register performs POST /v1/users/register.

func (*Client) Search

Search performs POST /v1/posts/search.

func (*Client) Update

Update performs POST /v1/users/update.

type ClientOption

type ClientOption func(*Client)

ClientOption mutates a generated client.

func WithAPIKeySecret

func WithAPIKeySecret(secret []byte) ClientOption

WithAPIKeySecret configures the HMAC secret used by api_key endpoints.

func WithBearerToken

func WithBearerToken(token string) ClientOption

WithBearerToken configures the JWT bearer token used by jwt-protected endpoints.

func WithHTTPClient

func WithHTTPClient(client *http.Client) ClientOption

WithHTTPClient overrides the HTTP transport.

func WithRequestEditor

func WithRequestEditor(fn RequestEditorFn) ClientOption

WithRequestEditor appends a request editor.

func WithWSHeaders

func WithWSHeaders(headers http.Header) ClientOption

WithWSHeaders configures extra headers for outbound WebSocket handshakes.

func WithWSOrigin

func WithWSOrigin(origin string) ClientOption

WithWSOrigin sets the Origin header for outbound WebSocket handshakes.

func WithoutTracePropagation added in v0.15.1

func WithoutTracePropagation() ClientOption

WithoutTracePropagation disables automatic correlation-id and traceparent header injection on outbound REST, GraphQL, and WebSocket calls. Injection is on by default; a request editor set via WithRequestEditor can still add or override these headers regardless of this option.

type GraphQLSubscription

type GraphQLSubscription[T any] struct {
	// contains filtered or unexported fields
}

GraphQLSubscription streams typed messages from a graphql-transport-ws subscription.

func (*GraphQLSubscription[T]) Close

func (s *GraphQLSubscription[T]) Close() error

Close terminates the subscription and underlying websocket.

func (*GraphQLSubscription[T]) Next

func (s *GraphQLSubscription[T]) Next() (T, error)

Next blocks until the next payload, completion, or error.

type HTTPError

type HTTPError struct {
	StatusCode int
	Body       []byte
}

HTTPError captures a non-2xx response from a generated REST endpoint.

func (*HTTPError) Error

func (e *HTTPError) Error() string

type JSONSocket

type JSONSocket[T any] struct {
	// contains filtered or unexported fields
}

JSONSocket wraps a typed JSON WebSocket endpoint.

func (*JSONSocket[T]) Close

func (s *JSONSocket[T]) Close() error

Close closes the underlying websocket.

func (*JSONSocket[T]) Receive

func (s *JSONSocket[T]) Receive() (T, error)

Receive blocks until the next JSON message arrives.

func (*JSONSocket[T]) Send

func (s *JSONSocket[T]) Send(msg T) error

Send writes one JSON message.

type RequestEditorFn

type RequestEditorFn func(context.Context, *http.Request) error

RequestEditorFn mutates outbound REST and GraphQL HTTP requests before auth is applied.

Jump to

Keyboard shortcuts

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