try go get if zip not found

pull/6/head
kun 2018-09-05 16:49:11 +08:00
parent aafa0fc010
commit 90c421639b
1 changed files with 4 additions and 1 deletions

View File

@ -39,11 +39,14 @@ func mainHandler(inner http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(os.Stdout, "goproxy: %s download %s\n", r.RemoteAddr, r.URL.Path)
if _, err := os.Stat(filepath.Join(cacheDir, r.URL.Path)); err != nil {
if strings.HasSuffix(r.URL.Path, ".info") || strings.HasSuffix(r.URL.Path, ".mod") {
if strings.HasSuffix(r.URL.Path, ".info") || strings.HasSuffix(r.URL.Path, ".mod") || strings.HasSuffix(r.URL.Path, ".zip") {
suffix := ".mod"
if strings.HasSuffix(r.URL.Path, ".info") {
suffix = ".info"
}
if strings.HasSuffix(r.URL.Path, ".zip") {
suffix = ".zip"
}
mod := strings.Split(r.URL.Path, "/@v/")
if len(mod) != 2 {
ReturnServerError(w, fmt.Errorf("bad module path:%s", r.URL.Path))