more functionality

This commit is contained in:
2021-04-10 22:14:45 -04:00
parent ece8baeaac
commit 91ff1a10d4
7 changed files with 200 additions and 15 deletions

View File

@@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"net/url"
"strconv"
@@ -18,6 +17,7 @@ type Queryer struct {
Root string
Client http.Client
Cache cache.Cache
Logger logger
}
type majorVersion struct {
@@ -59,17 +59,17 @@ func (q *Queryer) findLatestMajorVersion(module string) string {
}
func (q *Queryer) makeProxyRequest(mod string) libyear.Info {
log.Printf("makeProxyRequest for https://proxy.golang.org/%s", mod)
if q.Root == "" {
q.Root = "https://proxy.golang.org/"
}
q.Logger.Debugf("makeProxyRequest for %s/%s\n", q.Root, mod)
u, _ := url.Parse(q.Root)
u.Path = mod
i := q.Cache.Get(u.String())
if i.Version != "" {
log.Printf("cache hit for https://proxy.golang.org/%s", mod)
q.Logger.Debugf("cache hit for https://proxy.golang.org/%s\n", mod)
return i
}
req, err := http.NewRequest("GET", u.String(), nil)