Documentation
¶
Overview ¶
Package download provides http handlers that implement vgo's Download Protocol.
Index ¶
- Constants
- func InfoHandler(dp Protocol, lggr log.Entry) http.Handler
- func LatestHandler(dp Protocol, lggr log.Entry) http.Handler
- func ListHandler(dp Protocol, lggr log.Entry) http.Handler
- func LogEntryHandler(ph ProtocolHandler, opts *HandlerOpts) http.Handler
- func ModuleHandler(dp Protocol, lggr log.Entry) http.Handler
- func RegisterHandlers(r *mux.Router, opts *HandlerOpts)
- func ZipHandler(dp Protocol, lggr log.Entry) http.Handler
- type HandlerOpts
- type Opts
- type Protocol
- type ProtocolHandler
- type UpstreamLister
- type Wrapper
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.3.0
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.1.0
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.3.0
ModuleHandler implements GET baseURL/module/@v/version.mod
func RegisterHandlers ¶ added in v0.1.0
func RegisterHandlers(r *mux.Router, opts *HandlerOpts)
RegisterHandlers is a convenience method that registers all the download protocol paths for you.
Types ¶
type HandlerOpts ¶ added in v0.1.0
HandlerOpts are the generic options for a ProtocolHandler
type Opts ¶ added in v0.2.0
type Opts struct { Storage storage.Backend Stasher stash.Stasher Lister UpstreamLister }
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) (io.ReadCloser, error) }
Protocol is the download protocol which mirrors the http requests that cmd/go makes to the proxy.
type ProtocolHandler ¶ added in v0.1.0
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.
type UpstreamLister ¶ added in v0.2.0
type UpstreamLister interface {
List(ctx context.Context, mod string) (*storage.RevInfo, []string, error)
}
UpstreamLister retrieves a list of available module versions from upstream i.e. VCS, and a Storage backend.
func NewVCSLister ¶ added in v0.2.0
func NewVCSLister(goBinPath string, fs afero.Fs) UpstreamLister
NewVCSLister creates an UpstreamLister which uses VCS to fetch a list of available versions