Documentation ¶
Overview ¶
Package download provides http handlers that implement vgo's Download Protocol.
Index ¶
- Constants
- func InfoHandler(dp Protocol, lggr log.Entry, df *mode.DownloadFile) http.Handler
- func LatestHandler(dp Protocol, lggr log.Entry, df *mode.DownloadFile) http.Handler
- func ListHandler(dp Protocol, lggr log.Entry, df *mode.DownloadFile) http.Handler
- func LogEntryHandler(ph ProtocolHandler, opts *HandlerOpts) http.Handler
- func ModuleHandler(dp Protocol, lggr log.Entry, df *mode.DownloadFile) http.Handler
- func RegisterHandlers(r *mux.Router, opts *HandlerOpts)
- func ZipHandler(dp Protocol, lggr log.Entry, df *mode.DownloadFile) http.Handler
- type HandlerOpts
- type Opts
- type Protocol
- type ProtocolHandler
- type Wrapper
Constants ¶
const ( Strict = "strict" Offline = "offline" Fallback = "fallback" )
NetworkMode constants.
const PathLatest = "/{module:.+}/@latest"
PathLatest URL.
const PathList = "/{module:.+}/@v/list"
PathList URL.
const PathVersionInfo = "/{module:.+}/@v/{version}.info"
PathVersionInfo URL.
const PathVersionModule = "/{module:.+}/@v/{version}.mod"
PathVersionModule URL.
const PathVersionZip = "/{module:.+}/@v/{version}.zip"
PathVersionZip URL.
Variables ¶
This section is empty.
Functions ¶
func InfoHandler ¶ added in v0.8.1
InfoHandler implements GET baseURL/module/@v/version.info.
func LatestHandler ¶
LatestHandler implements GET baseURL/module/@latest.
func ListHandler ¶
ListHandler implements GET baseURL/module/@v/list.
func LogEntryHandler ¶ added in v0.8.1
func LogEntryHandler(ph ProtocolHandler, opts *HandlerOpts) http.Handler
LogEntryHandler pulls a log entry from the request context. Thanks to the LogEntryMiddleware, we should have a log entry stored in the context for each request with request-specific fields. This will grab the entry and pass it to the protocol handlers.
func ModuleHandler ¶ added in v0.8.1
ModuleHandler implements GET baseURL/module/@v/version.mod.
func RegisterHandlers ¶ added in v0.8.1
func RegisterHandlers(r *mux.Router, opts *HandlerOpts)
RegisterHandlers is a convenience method that registers all the download protocol paths for you.
func ZipHandler ¶ added in v0.8.1
ZipHandler implements GET baseURL/module/@v/version.zip.
Types ¶
type HandlerOpts ¶ added in v0.8.1
type HandlerOpts struct { Protocol Protocol Logger *log.Logger DownloadFile *mode.DownloadFile }
HandlerOpts are the generic options for a ProtocolHandler.
type Opts ¶ added in v0.8.1
type Opts struct { Storage storage.Backend Stasher stash.Stasher Lister module.UpstreamLister DownloadFile *mode.DownloadFile NetworkMode string }
Opts specifies download protocol options to avoid long func signature.
type Protocol ¶
type Protocol interface { // List implements GET /{module}/@v/list List(ctx context.Context, mod string) ([]string, error) // Info implements GET /{module}/@v/{version}.info Info(ctx context.Context, mod, ver string) ([]byte, error) // Latest implements GET /{module}/@latest Latest(ctx context.Context, mod string) (*storage.RevInfo, error) // GoMod implements GET /{module}/@v/{version}.mod GoMod(ctx context.Context, mod, ver string) ([]byte, error) // Zip implements GET /{module}/@v/{version}.zip Zip(ctx context.Context, mod, ver string) (storage.SizeReadCloser, error) }
Protocol is the download protocol which mirrors the http requests that cmd/go makes to the proxy.
type ProtocolHandler ¶ added in v0.8.1
ProtocolHandler is a function that takes all that it needs to return a ready-to-go http handler that serves up cmd/go's download protocol.