Documentation
¶
Index ¶
- Variables
- func ParseURL(urlBaseRaw string, urlPartsRaw ...string) (*url.URL, error)
- func WithProgress(ctx context.Context, p *progress.Progress) context.Context
- type Client
- func (c *Client) Download(ctx context.Context, u *url.URL, w ...io.Writer) error
- func (c *Client) DownloadTo(ctx context.Context, u *url.URL, out string) error
- func (c *Client) Exists(ctx context.Context, urlBaseRaw string, urlPartsRaw ...string) (bool, error)
- func (c *Client) RestyClient() *resty.Client
Constants ¶
This section is empty.
Variables ¶
var ( ErrClientConfiguration = errors.New("client misconfigured") ErrHTTPResponseStatusCode = errors.New("received error status code") ErrInvalidURL = errors.New("invalid URL") ErrMissingSize = errors.New("missing progress size") ErrMissingURL = errors.New("missing URL") ErrRequestFailed = errors.New("request failed") ErrUnexpectedRedirect = errors.New("unexpected redirect") )
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A struct implementing an HTTP client with simple methods for file downloads.
func NewWithRedirectDomains ¶
Creates a new 'Client' with the provided domains allowed for redirects. If none are provided, then no redirects are permitted.
func (*Client) Download ¶
Downloads the provided asset, copying the response to all of the provided 'io.Writer' writers. Reports progress to a 'progress.Progress' set on the provided context.
func (*Client) DownloadTo ¶
Downloads the provided asset to a specified file 'out'. Reports progress to a 'progress.Progress' set on the provided context.
func (*Client) Exists ¶
func (c *Client) Exists(ctx context.Context, urlBaseRaw string, urlPartsRaw ...string) (bool, error)
Issues a 'HEAD' request to test whether or not the URL is reachable.
func (*Client) RestyClient ¶
func (c *Client) RestyClient() *resty.Client
RestyClient returns the underlying 'resty.Client'. Exposing this allows for tests in other packages to stub responses.
TODO: Find an alternative way of allowing other packages to stub responses without exposing the use of 'resty'.