|
|
@ -141,46 +141,6 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
|
w.WriteHeader(http.StatusNotFound)
|
|
|
|
w.WriteHeader(http.StatusNotFound)
|
|
|
|
w.Write([]byte("not found"))
|
|
|
|
w.Write([]byte("not found"))
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
// switch r.URL.Path {
|
|
|
|
|
|
|
|
// 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")
|
|
|
|
|
|
|
|
// 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")
|
|
|
|
|
|
|
|
// case "/modules/orel.li/fart/@latest",
|
|
|
|
|
|
|
|
// "/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.Encode(versionInfo{
|
|
|
|
|
|
|
|
// Version: "v0.0.3",
|
|
|
|
|
|
|
|
// Time: time.Now(),
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
// 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")
|
|
|
|
|
|
|
|
// 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{
|
|
|
|
|
|
|
|
// Path: "orel.li/fart",
|
|
|
|
|
|
|
|
// Version: "v0.0.3",
|
|
|
|
|
|
|
|
// }, "/home/jorelli/mir/modules/orel.li/fart")
|
|
|
|
|
|
|
|
// if err != nil {
|
|
|
|
|
|
|
|
// log_error.Printf("zip error: %v", err)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// case "/":
|
|
|
|
|
|
|
|
// w.WriteHeader(http.StatusOK)
|
|
|
|
|
|
|
|
// default:
|
|
|
|
|
|
|
|
// w.WriteHeader(http.StatusNotFound)
|
|
|
|
|
|
|
|
// w.Write([]byte("not found"))
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// locate searches our module root for a given modpath
|
|
|
|
// locate searches our module root for a given modpath
|
|
|
@ -334,7 +294,9 @@ func (h handler) modfile(modpath, modversion string, w http.ResponseWriter, r *h
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
defer f.Close()
|
|
|
|
|
|
|
|
|
|
|
|
io.Copy(w, f)
|
|
|
|
if _, err := io.Copy(w, f); err != nil {
|
|
|
|
|
|
|
|
log_error.Printf("error copying modfile contents for %s version %s: %v", modpath, modversion, err)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// zipfile serves the $base/$module/@v/$version.zip endpoint
|
|
|
|
// zipfile serves the $base/$module/@v/$version.zip endpoint
|
|
|
|