pkgsite: golang.org/x/pkgsite/internal/proxy Index | Files

package proxy

import "golang.org/x/pkgsite/internal/proxy"

Index

Package Files

client.go test_helper.go

func TestProxy Uses

func TestProxy(modules []*Module) *http.ServeMux

TestProxy implements a fake proxy, hosting the given modules. If modules is nil, it serves the modules in the testdata directory.

type Client Uses

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.

func New Uses

func New(u string) (_ *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.

func SetupTestProxy Uses

func SetupTestProxy(t *testing.T, modules []*Module) (*Client, func())

SetupTestProxy 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 TestProxyServer Uses

func TestProxyServer(t *testing.T, proxyMux *http.ServeMux) (*Client, func())

TestProxyServer starts serving proxyMux locally. It returns a client to the server and a function to shut down the server.

func (*Client) GetInfo Uses

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 (*Client) GetMod Uses

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 (*Client) GetZip Uses

func (c *Client) GetZip(ctx context.Context, requestedPath, requestedVersion string) (_ *zip.Reader, err error)

GetZip makes a request to $GOPROXY/<path>/@v/<resolvedVersion>.zip and transforms that data into a *zip.Reader. <resolvedVersion> is obtained by first making a request to $GOPROXY/<path>/@v/<requestedVersion>.info to obtained the valid semantic version.

func (*Client) ListVersions Uses

func (c *Client) ListVersions(ctx context.Context, modulePath string) ([]string, error)

ListVersions makes a request to $GOPROXY/<path>/@v/list and returns the resulting version strings.

type Module Uses

type Module struct {
    ModulePath string
    Version    string
    Files      map[string]string
    // contains filtered or unexported fields
}

Module represents a module version used to generate testdata.

type VersionInfo Uses

type VersionInfo struct {
    Version string
    Time    time.Time
}

A VersionInfo contains metadata about a given version of a module.

Package proxy imports 21 packages (graph) and is imported by 10 packages. Updated 2020-08-05. Refresh now. Tools for package owners.