package proxy

Import Path
	golang.org/x/pkgsite/internal/proxy (on go.dev)

Dependency Relation
	imports 26 packages, and imported by 6 packages

Involved Source Files Package proxy provides a client for interacting with a proxy. module.go server.go test_helper.go
Package-Level Type Names (total 4, all are exported)
/* sort exporteds by: | */
A Client is used by the fetch service to communicate with a module proxy. It handles all methods defined by go help goproxy. FetchDisabled reports whether proxy fetch is disabled. 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. Mod makes a request to $GOPROXY/<module>/@v/<resolvedVersion>.mod and returns the raw data. Versions makes a request to $GOPROXY/<path>/@v/list and returns the resulting version strings. 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. WithZipCache returns a new client that caches the last zip it downloads (not thread-safely). 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. 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. func New(u string) (_ *Client, err error) func NewClientForServer(s *Server) (*Client, func(), error) func SetupTestClient(t *testing.T, modules []*Module) (*Client, func()) func (*Client).WithFetchDisabled() *Client func (*Client).WithZipCache() *Client func golang.org/x/pkgsite/internal/fetch.FetchModule(ctx context.Context, modulePath, requestedVersion string, proxyClient *Client, sourceClient *source.Client) (fr *fetch.FetchResult) func golang.org/x/pkgsite/internal/fetch.GetInfo(ctx context.Context, modulePath, requestedVersion string, proxyClient *Client) (_ *VersionInfo, err error) func golang.org/x/pkgsite/internal/fetch.LatestModuleVersions(ctx context.Context, modulePath string, prox *Client, hasGoMod func(v string) (bool, error)) (info *internal.LatestModuleVersions, err error) func golang.org/x/pkgsite/internal/frontend.FetchAndUpdateState(ctx context.Context, modulePath, requestedVersion string, proxyClient *Client, sourceClient *source.Client, db *postgres.DB) (_ int, err error) func golang.org/x/pkgsite/internal/proxydatasource.New(proxyClient *Client) *proxydatasource.DataSource func golang.org/x/pkgsite/internal/proxydatasource.NewBypassingLicenseCheck(c *Client) *proxydatasource.DataSource func golang.org/x/pkgsite/internal/proxydatasource.NewForTesting(proxyClient *Client) *proxydatasource.DataSource
Module represents a module version used by the proxy server. Files map[string]string ModulePath string // if true, behaves like it's uncached Version string AddFile returns a copy of m with an additional file. It panics if the filename is already present. ChangePath returns a copy of m with a different module path. ChangeVersion returns a copy of m with a different version. DeleteFile returns a copy of m with filename removed. It panics if filename is not present. ReplaceFile returns a copy of m with different contents for filename. It panics if filename is not present. func FindModule(mods []*Module, path, version string) *Module func LoadTestModules(dir string) []*Module func (*Module).AddFile(filename, contents string) *Module func (*Module).ChangePath(modulePath string) *Module func (*Module).ChangeVersion(version string) *Module func (*Module).DeleteFile(filename string) *Module func (*Module).ReplaceFile(filename, contents string) *Module func FindModule(mods []*Module, path, version string) *Module func NewServer(modules []*Module) *Server func SetupTestClient(t *testing.T, modules []*Module) (*Client, func()) func (*Server).AddModule(m *Module) func (*Server).AddModuleNoVersions(m *Module)
Server represents a proxy server containing the specified modules. AddModule adds an additional module to the server. AddModuleNoLatest adds a module to the server, but the @v/list endpoint will return nothing and @latest endpoint will serve a 410. For testing the unusual case where a module exists but there is no version information. AddRoute adds an additional handler to the server. (*T) ZipRequests() int func NewServer(modules []*Module) *Server func NewClientForServer(s *Server) (*Client, func(), error)
A VersionInfo contains metadata about a given version of a module. Time time.Time Version string func (*Client).Info(ctx context.Context, modulePath, requestedVersion string) (_ *VersionInfo, err error) func golang.org/x/pkgsite/internal/fetch.GetInfo(ctx context.Context, modulePath, requestedVersion string, proxyClient *Client) (_ *VersionInfo, err error)
Package-Level Functions (total 10, in which 6 are exported)
FindModule returns the module in mods with the given path and version, or nil if there isn't one. An empty version argument matches any version.
LoadTestModules reads the modules in the given directory. Each file in that directory with a .txtar extension should be named "path@version" and should be in txtar format (golang.org/x/tools/txtar). The path part of the filename will be preceded by "example.com/" and colons will be replaced by slashes to form a full module path. The file contents are used verbatim except that some variables beginning with "$" are substituted with predefined strings. LoadTestModules panics if there is an error reading any of the files.
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.
NewServer returns a proxy Server that serves the provided modules.
SetupTestClient creates a fake module proxy for testing using the given test version information. It returns a function for tearing down the proxy after the test is completed and a Client for interacting with the test proxy.
Package-Level Variables (only one, which is unexported)
Package-Level Constants (total 2, neither is exported)