Documentation
¶
Overview ¶
Package httpclient is a client of the resources' HTTP API
Index ¶
- type Client
- func (c *Client) CreateResource(ctx context.Context, req schema.ResourceCreateRequest, file string, ...) (*schema.Resource, error)
- func (c *Client) DeleteResource(ctx context.Context, hash string, req schema.ResourceRequest) (*schema.Resource, error)
- func (c *Client) GetResource(ctx context.Context, hash string, req schema.ResourceRequest) (*schema.Resource, error)
- func (c *Client) ListResources(ctx context.Context, req schema.ResourceListRequest) (*schema.ResourceList, error)
- func (c *Client) ReadResource(ctx context.Context, hash string, req schema.ResourceRequest, w io.Writer) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is a client of the resources' HTTP API, which wraps the base HTTP client, with typed methods for its requests
func New ¶
New returns a client of the resources' API, at the URL, which is the server's API endpoint, such as http://localhost:8084/api, with the options
func (*Client) CreateResource ¶
func (c *Client) CreateResource(ctx context.Context, req schema.ResourceCreateRequest, file string, content io.Reader) (*schema.Resource, error)
CreateResource uploads the content, as it's read, as the request's body, as a resource, which is what the request says it is, whose name, when it isn't given, is the file's, and whose type, when it isn't given, is detected, and returns it. The upload isn't timed out, as a large file can take a while.
func (*Client) DeleteResource ¶
func (c *Client) DeleteResource(ctx context.Context, hash string, req schema.ResourceRequest) (*schema.Resource, error)
DeleteResource deletes the resource with the hash, on its own, or in the request's session, and returns it, as it was
func (*Client) GetResource ¶
func (c *Client) GetResource(ctx context.Context, hash string, req schema.ResourceRequest) (*schema.Resource, error)
GetResource returns the resource with the hash, on its own, or in the request's session
func (*Client) ListResources ¶
func (c *Client) ListResources(ctx context.Context, req schema.ResourceListRequest) (*schema.ResourceList, error)
ListResources returns the resources on their own, or those in the request's session, the most recently used first, and how many there are
func (*Client) ReadResource ¶
func (c *Client) ReadResource(ctx context.Context, hash string, req schema.ResourceRequest, w io.Writer) (string, error)
ReadResource writes the content of the resource with the hash, on its own, or in the request's session, to the writer, as it's read, and returns its type. The download isn't timed out, as a large file can take a while.