import "golang.org/x/pkgsite/internal/proxy"
Package proxy provides a client for interacting with a proxy.
client.go server.go test_helper.go
type Client struct {
// 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.
New constructs a *Client using the provided url, which is expected to be an absolute URI that can be directly passed to http.Get.
NewClientForServer starts serving proxyMux locally. It returns a client to the server and a function to shut down the server.
SetupTestClient creates a fake module proxy for testing using the given test version information. If modules is nil, it will default to hosting the modules in the testdata directory.
It returns a function for tearing down the proxy after the test is completed and a Client for interacting with the test proxy.
func (c *Client) GetInfo(ctx context.Context, modulePath, requestedVersion string) (_ *VersionInfo, err error)
GetInfo makes a request to $GOPROXY/<module>/@v/<requestedVersion>.info and transforms that data into a *VersionInfo.
func (c *Client) GetInfoNoFetch(ctx context.Context, modulePath, requestedVersion string) (_ *VersionInfo, err error)
GetInfoNoFetch behaves like GetInfo, except that it sets the Disable-Module-Fetch header so that the proxy does not fetch a module it doesn't already know about.
func (c *Client) GetMod(ctx context.Context, modulePath, resolvedVersion string) (_ []byte, err error)
GetMod makes a request to $GOPROXY/<module>/@v/<resolvedVersion>.mod and returns the raw data.
func (c *Client) GetZip(ctx context.Context, modulePath, resolvedVersion string) (_ *zip.Reader, err error)
GetZip 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.
func (c *Client) GetZipSize(ctx context.Context, modulePath, resolvedVersion string) (_ int64, err error)
GetZipSize gets the size in bytes of the zip from the proxy, without downloading it. The version must be resolved, as by a call to Client.GetInfo.
ListVersions makes a request to $GOPROXY/<path>/@v/list and returns the resulting version strings.
type Module struct { ModulePath string Version string Files map[string]string NotCached bool // if true, behaves like it's uncached // contains filtered or unexported fields }
Module represents a module version used by the proxy server.
type Server struct {
// contains filtered or unexported fields
}
Server represents a proxy server containing the specified modules.
NewServer returns a proxy Server that serves the provided modules.
AddModule adds an additional module to the server.
AddRoute adds an additional handler to the server.
A VersionInfo contains metadata about a given version of a module.
Package proxy imports 22 packages (graph) and is imported by 10 packages. Updated 2021-01-17. Refresh now. Tools for package owners.