|
|
@ -62,19 +62,30 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
|
|
|
|
|
|
switch r.URL.Path {
|
|
|
|
switch r.URL.Path {
|
|
|
|
case "/fart":
|
|
|
|
case "/fart":
|
|
|
|
|
|
|
|
// Step 1: a request comes in at orel.li. This page contains a meta tag
|
|
|
|
|
|
|
|
// indicating where the package contents may be found, and which backend
|
|
|
|
|
|
|
|
// is serving the package.
|
|
|
|
serveFile(w, "meta/fart/root.html")
|
|
|
|
serveFile(w, "meta/fart/root.html")
|
|
|
|
case "/modules/orel.li/fart/@v/list":
|
|
|
|
case "/modules/orel.li/fart/@v/list":
|
|
|
|
|
|
|
|
// Step 2: list all of the versions for the package. Versions may be
|
|
|
|
|
|
|
|
// available but unlisted.
|
|
|
|
serveFile(w, "meta/fart/version-list")
|
|
|
|
serveFile(w, "meta/fart/version-list")
|
|
|
|
case "/modules/orel.li/fart/@latest",
|
|
|
|
case "/modules/orel.li/fart/@latest",
|
|
|
|
"/modules/orel.li/fart/@v/v0.0.3.info":
|
|
|
|
"/modules/orel.li/fart/@v/v0.0.3.info":
|
|
|
|
|
|
|
|
// Step 3: get info for the version, which is just a timestamp at the
|
|
|
|
|
|
|
|
// moment.
|
|
|
|
e := json.NewEncoder(w)
|
|
|
|
e := json.NewEncoder(w)
|
|
|
|
e.Encode(versionInfo{
|
|
|
|
e.Encode(versionInfo{
|
|
|
|
Version: "v0.0.3",
|
|
|
|
Version: "v0.0.3",
|
|
|
|
Time: time.Now(),
|
|
|
|
Time: time.Now(),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
case "/modules/orel.li/fart/@v/v0.0.3.mod":
|
|
|
|
case "/modules/orel.li/fart/@v/v0.0.3.mod":
|
|
|
|
|
|
|
|
// Step 4: retrieve the modfile for the package, informing go mod of
|
|
|
|
|
|
|
|
// any transitive dependencies.
|
|
|
|
serveFile(w, "meta/fart/modfile")
|
|
|
|
serveFile(w, "meta/fart/modfile")
|
|
|
|
case "/modules/orel.li/fart/@v/v0.0.3.zip":
|
|
|
|
case "/modules/orel.li/fart/@v/v0.0.3.zip":
|
|
|
|
|
|
|
|
// Step 5: retrieve the source code contents for a package, as a
|
|
|
|
|
|
|
|
// specially-formatted zip file.
|
|
|
|
err := zip.CreateFromDir(w, module.Version{
|
|
|
|
err := zip.CreateFromDir(w, module.Version{
|
|
|
|
Path: "orel.li/fart",
|
|
|
|
Path: "orel.li/fart",
|
|
|
|
Version: "v0.0.3",
|
|
|
|
Version: "v0.0.3",
|
|
|
|