Documentation
¶
Overview ¶
Package jsonapi interacts with HTTP JSON APIs. In OONI we use this code when accessing API like, e.g., the OONI collector.
Index ¶
- type Client
- func (c *Client) Create(ctx context.Context, resourcePath string, input, output interface{}) error
- func (c *Client) Read(ctx context.Context, resourcePath string, output interface{}) error
- func (c *Client) ReadWithQuery(ctx context.Context, resourcePath string, query url.Values, output interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// BaseURL is the base URL of the API.
BaseURL string
// HTTPClient is the http client to use.
HTTPClient *http.Client
// Logger is the logger to use.
Logger log.Logger
// UserAgent is the user agent to use.
UserAgent string
}
Client is a client for a JSON API.
func (*Client) Create ¶
func (c *Client) Create( ctx context.Context, resourcePath string, input, output interface{}, ) error
Create creates a JSON subresource of the resource at resourcePath using the JSON document at input and returning the result into the JSON document at output. The request is bounded by the context's lifetime. Returns the error that occurred.
Click to show internal directories.
Click to hide internal directories.