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 ¶
- Variables
- func WithCorrelationID(ctx context.Context, id string) context.Context
- func WithTraceParent(ctx context.Context, traceparent string) context.Context
- type BinarySocket
- type Client
- func (c *Client) ConnectBinary(ctx context.Context) (*BinarySocket, error)
- func (c *Client) ConnectFeed(ctx context.Context) (*JSONSocket[types.FeedMsg], error)
- func (c *Client) Create(ctx context.Context, req *types.PostCreateReq) (*types.PostCreateResp, error)
- func (c *Client) GraphQLCreatePost(ctx context.Context, req *types.PostCreateReq) (*types.PostCreateResp, error)
- func (c *Client) GraphQLRegisterUser(ctx context.Context, req *types.RegisterReq) (*types.RegisterResp, error)
- func (c *Client) GraphQLSearchPosts(ctx context.Context, req *types.PostSearchReq) (*types.PostSearchResp, error)
- func (c *Client) GraphQLSubscribeBinaryStream(ctx context.Context) (*GraphQLSubscription[types.BinaryMsg], error)
- func (c *Client) GraphQLSubscribeFeedEvents(ctx context.Context) (*GraphQLSubscription[types.FeedMsg], error)
- func (c *Client) GraphQLUpdateUser(ctx context.Context, req *types.UserUpdateReq) (*types.UserUpdateResp, error)
- func (c *Client) Register(ctx context.Context, req *types.RegisterReq) (*types.RegisterResp, error)
- func (c *Client) Search(ctx context.Context, req *types.PostSearchReq) (*types.PostSearchResp, error)
- func (c *Client) Update(ctx context.Context, req *types.UserUpdateReq) (*types.UserUpdateResp, error)
- type ClientOption
- func WithAPIKeySecret(secret []byte) ClientOption
- func WithBearerToken(token string) ClientOption
- func WithHTTPClient(client *http.Client) ClientOption
- func WithRequestEditor(fn RequestEditorFn) ClientOption
- func WithWSHeaders(headers http.Header) ClientOption
- func WithWSOrigin(origin string) ClientOption
- func WithoutTracePropagation() ClientOption
- type GraphQLSubscription
- type HTTPError
- type JSONSocket
- type RequestEditorFn
Constants ¶
This section is empty.
Variables ¶
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
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
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 ¶
ConnectFeed opens /ws/feed.
func (*Client) Create ¶
func (c *Client) Create(ctx context.Context, req *types.PostCreateReq) (*types.PostCreateResp, error)
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 ¶
func (c *Client) Search(ctx context.Context, req *types.PostSearchReq) (*types.PostSearchResp, error)
Search performs POST /v1/posts/search.
func (*Client) Update ¶
func (c *Client) Update(ctx context.Context, req *types.UserUpdateReq) (*types.UserUpdateResp, error)
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 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.