client

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

package client provides methods for SFO Museum API clients.

Index

Constants

View Source
const API_ENDPOINT string = "https://api.sfomuseum.org/rest"

API_ENDPOINT is the default endpoint for the api.sfomuseum.org API.

Variables

This section is empty.

Functions

func ExecuteMethodPaginatedWithClient

func ExecuteMethodPaginatedWithClient(ctx context.Context, cl Client, verb string, args *url.Values) iter.Seq2[io.ReadSeeker, error]

ExecuteMethodPaginatedWithClient performs as many paginated API requests for a given method. It returns a `iter.Seq2[io.ReadSeeker, error]` instance which can be iterated through to yield each API result.

func RegisterClient

func RegisterClient(ctx context.Context, scheme string, f ClientInitializeFunc) error

Register a new URI scheme and ClientInitializeFunc function for a implementation of the Client interface.

func Schemes

func Schemes() []string

Return a list of URI schemes for registered implementations of the Client interface.

Types

type Client

type Client interface {
	// ExecuteMethod performs an API method request.
	ExecuteMethod(context.Context, string, *url.Values) (io.ReadSeekCloser, error)
}

type Client is an interface for SFO Museum API client implementations.

func NewClient

func NewClient(ctx context.Context, uri string) (Client, error)

Create a new instance of the Client interface. Client instances are created by passing in a context.Context instance and a URI string. The form and substance of URI strings are specific to their implementations.

For example to create a OAuth2Client you might write:

cl, _ := client.NewClient(ctx, "oauth2://collection?access_token={TOKEN}")

func NewOAuth2Client

func NewOAuth2Client(ctx context.Context, uri string) (Client, error)

NewOAuth2Client creates a new `OAuth2Client` instance configured by 'uri' which is expected to take the form of:

oauth2://{HOST}/{PATH}?{PARAMETERS}

Where {PARAMETERS} is: - `?access_token={TOKEN}` A valid OAuth2 access token. - `?insecure={BOOLEAN}` A boolean flag signaling that TLS verification will be skipped.

type ClientInitializeFunc

type ClientInitializeFunc func(context.Context, string) (Client, error)

The initialization function signature for implementation of the Client interface.

type OAuth2Client

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

OAuth2Client implements the `Client` interface for API endpoints that require OAuth2 access token authentication.

func (*OAuth2Client) ExecuteMethod

func (cl *OAuth2Client) ExecuteMethod(ctx context.Context, verb string, args *url.Values) (io.ReadSeekCloser, error)

ExecuteMethod will perform an API request derived from 'verb' and 'args'.

Jump to

Keyboard shortcuts

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