Documentation
¶
Overview ¶
Package froda provides a slink-compatible client for calling XRPC APIs.
Overview ¶
Using an Old English name meaning "wise by experience", froda implements the calling interface used by the XRPC clients generated by slink.
Froda includes options for configuring connections to upstream hosts including both servers and proxies. Upstream addresses can be either TCP sockets (for typical HTTP networking) or Linux abstract sockets for communication with local hosts, such as sidecar proxies.
Froda configuration includes the following values, which can either be set using fields of the ClientOptions structure or as environment variables:
Environment Variable | Header | Purpose ----------------------|---------------|----------------------------------------------------------- SLINK_HOST | host | The host to receive the request SLINK_AUTHORIZATION | authorization | The HTTP authorization header to be sent with the request SLINK_ATPROTOPROXY | atproto-proxy | An upstream service that should ultimately receive the request SLINK_PROXYSESSION | proxy-session | A session ID that corresponds to a user auth token SLINK_USERDID | user-did | The DID of the user associated with the proxy session
The example below uses froda with an XRPC client generated by slink.
c := froda.NewClientWithOptions(froda.ClientOptions{
Host: senderDidDocument.Service[0].ServiceEndpoint,
})
result, err := xrpc.ComATProtoServerCreateSession(cmd.Context(), c, &xrpc.ComATProtoServerCreateSession_Input{
Identifier: senderDid,
Password: senderPassword,
})
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Host string
Authorization string
ATProtoProxy string
ProxySession string
UserDid string
}
Client contains configurable settings for the client.
func NewClient ¶
func NewClient() *Client
NewClient creates a new client that can be configured directly or with environment variables.
func NewClientWithOptions ¶
func NewClientWithOptions(options ClientOptions) *Client
NewClientWithOptions creates a client using a user-specified set of options.
func (*Client) Do ¶
func (c *Client) Do( ctx context.Context, kind slink.RequestType, contentType string, method string, params map[string]any, bodyvalue any, out any, ) error
Do performs an HTTP request using XRPC conventions.
func (*Client) SetSessionHeaders ¶
SetSessionHeaders configures a client with headers sent with a request. This can be used to read caller identity sent by an authenticating proxy.
type ClientOptions ¶
type ClientOptions struct {
Host string
Authorization string
ATProtoProxy string
ProxySession string
UserDid string
}
ClientOptions contains values that can be passed to NewClientWithOptions.