Documentation
¶
Overview ¶
Package download provides buffalo handlers that implement vgo's Download Protocol.
Index ¶
- Constants
- func LatestHandler(dp Protocol, lggr log.Entry, eng *render.Engine) buffalo.Handler
- func ListHandler(dp Protocol, lggr log.Entry, eng *render.Engine) buffalo.Handler
- func LogEntryHandler(ph ProtocolHandler, opts *HandlerOpts) buffalo.Handler
- func RegisterHandlers(app *buffalo.App, opts *HandlerOpts)
- func VersionInfoHandler(dp Protocol, lggr log.Entry, eng *render.Engine) buffalo.Handler
- func VersionModuleHandler(dp Protocol, lggr log.Entry, eng *render.Engine) buffalo.Handler
- func VersionZipHandler(dp Protocol, lggr log.Entry, eng *render.Engine) buffalo.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 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) buffalo.Handler
LogEntryHandler pulls a log entry from the buffalo 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 RegisterHandlers ¶ added in v0.1.0
func RegisterHandlers(app *buffalo.App, opts *HandlerOpts)
RegisterHandlers is a convenience method that registers all the download protocol paths for you.
func VersionInfoHandler ¶
VersionInfoHandler implements GET baseURL/module/@v/version.info
func VersionModuleHandler ¶
VersionModuleHandler implements GET baseURL/module/@v/version.mod
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 buffalo handler that serves up cmd/go's download protocol.
type UpstreamLister ¶ added in v0.2.0
UpstreamLister retrieves a list o 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