Documentation ¶
Overview ¶
Package proxy provides a client for interacting with a proxy.
Index ¶
- Constants
- type Client
- func (c *Client) EscapedURL(modulePath, requestedVersion, suffix string) (_ string, err error)
- func (c *Client) FetchDisabled() bool
- func (c *Client) Info(ctx context.Context, modulePath, requestedVersion string) (_ *VersionInfo, err error)
- func (c *Client) Mod(ctx context.Context, modulePath, resolvedVersion string) (_ []byte, err error)
- func (c *Client) Versions(ctx context.Context, modulePath string) (_ []string, err error)
- func (c *Client) WithCache() *Client
- func (c *Client) WithFetchDisabled() *Client
- func (c *Client) Zip(ctx context.Context, modulePath, resolvedVersion string) (_ *zip.Reader, err error)
- func (c *Client) ZipSize(ctx context.Context, modulePath, resolvedVersion string) (_ int64, err error)
- type VersionInfo
Constants ¶
const DisableFetchHeader = "Disable-Module-Fetch"
Setting this header to true prevents the proxy from fetching uncached modules.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // Client used for HTTP requests. It is mutable for testing purposes. HTTPClient *http.Client // contains filtered or unexported fields }
A Client is used by the fetch service to communicate with a module proxy. It handles all methods defined by go help goproxy.
func New ¶
func New(u string, transport http.RoundTripper) (_ *Client, err error)
New constructs a *Client using the provided url, which is expected to be an absolute URI that can be directly passed to http.Get. The optional transport parameter is used by the underlying http client.
func (*Client) EscapedURL ¶
func (*Client) FetchDisabled ¶
FetchDisabled reports whether proxy fetch is disabled.
func (*Client) Info ¶
func (c *Client) Info(ctx context.Context, modulePath, requestedVersion string) (_ *VersionInfo, err error)
Info makes a request to $GOPROXY/<module>/@v/<requestedVersion>.info and transforms that data into a *VersionInfo. If requestedVersion is internal.LatestVersion, it uses the proxy's @latest endpoint instead.
func (*Client) Mod ¶
Mod makes a request to $GOPROXY/<module>/@v/<resolvedVersion>.mod and returns the raw data.
func (*Client) Versions ¶
Versions makes a request to $GOPROXY/<path>/@v/list and returns the resulting version strings.
func (*Client) WithFetchDisabled ¶
WithFetchDisabled returns a new client that sets the Disable-Module-Fetch header so that the proxy does not fetch a module it doesn't already know about.
func (*Client) Zip ¶
func (c *Client) Zip(ctx context.Context, modulePath, resolvedVersion string) (_ *zip.Reader, err error)
Zip makes a request to $GOPROXY/<modulePath>/@v/<resolvedVersion>.zip and transforms that data into a *zip.Reader. <resolvedVersion> must have already been resolved by first making a request to $GOPROXY/<modulePath>/@v/<requestedVersion>.info to obtained the valid semantic version.
type VersionInfo ¶
A VersionInfo contains metadata about a given version of a module.