proxy

package
Version: v0.0.0-...-8893da0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2022 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package proxy provides a client for interacting with a proxy.

Index

Constants

View Source
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) (_ *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 (*Client) EscapedURL

func (c *Client) EscapedURL(modulePath, requestedVersion, suffix string) (_ string, err error)

func (*Client) FetchDisabled

func (c *Client) FetchDisabled() bool

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

func (c *Client) Mod(ctx context.Context, modulePath, resolvedVersion string) (_ []byte, err error)

Mod makes a request to $GOPROXY/<module>/@v/<resolvedVersion>.mod and returns the raw data.

func (*Client) Versions

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

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

func (*Client) WithCache

func (c *Client) WithCache() *Client

WithCache returns a new client that caches some RPCs.

func (*Client) WithFetchDisabled

func (c *Client) WithFetchDisabled() *Client

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.

func (*Client) ZipSize

func (c *Client) ZipSize(ctx context.Context, modulePath, resolvedVersion string) (_ int64, err error)

ZipSize 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.Info.

type VersionInfo

type VersionInfo struct {
	Version string
	Time    time.Time
}

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

Source Files

Directories

Path Synopsis
Package proxytest supports testing with the proxy.
Package proxytest supports testing with the proxy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL