prow/github/client.go
func (c *Client) readPaginatedResultsWithValues(path string, values url.Values, accept string, newObj func() interface{}, accumulate func(interface{})) error {
	pagedPath := path
	if len(values) > 0 {
		pagedPath += "?" + values.Encode()
	}
	for {
		resp, err := c.requestRetry(http.MethodGet, pagedPath, accept, nil)
		if err != nil {
			return err
		}
		defer resp.Body.Close()
		if resp.StatusCode < 200 || resp.StatusCode > 299 {
			return fmt.Errorf("return code not 2XX: %s", resp.Status)
		}

		b, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			return err
		}

		obj := newObj()
		if err := json.Unmarshal(b, obj); err != nil {
			return err
		}

		accumulate(obj)

		link := parseLinks(resp.Header.Get("Link"))["next"]
		if link == "" {
			break
		}
		u, err := url.Parse(link)
		if err != nil {
			return fmt.Errorf("failed to parse 'next' link: %v", err)
		}
		pagedPath = u.RequestURI()
	}
	return nil
}
func (c *Client) readPaginatedResultsWithValues(path string, values url.Values, accept string, newObj func() interface{}, accumulate func(interface{})) error {
	pagedPath := path
	if len(values) > 0 {
		pagedPath += "?" + values.Encode()
	}
	for {
		resp, err := c.requestRetry(http.MethodGet, pagedPath, accept, nil)
		if err != nil {
			return err
		}
		defer resp.Body.Close()
		if resp.StatusCode < 200 || resp.StatusCode > 299 {
			return fmt.Errorf("return code not 2XX: %s", resp.Status)
		}

		b, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			return err
		}

		obj := newObj()
		if err := json.Unmarshal(b, obj); err != nil {
			return err
		}

		accumulate(obj)

		link := parseLinks(resp.Header.Get("Link"))["next"]
		if link == "" {
			break
		}
		u, err := url.Parse(link)
		if err != nil {
			return fmt.Errorf("failed to parse 'next' link: %v", err)
		}
		pagedPath = u.RequestURI()
	}
	return nil
}
func ( c * Client ) readPaginatedResultsWithValues ( path string , values url . Values , accept string , newObj func ( ) interface { } , accumulate func ( interface { } ) ) error { pagedPath := path if len ( values ) > 0 { pagedPath += " " + values . Encode ( ) } for { resp , err := c . requestRetry ( http . MethodGet , pagedPath , accept , nil ) if err != nil { return err } defer resp . Body . Close ( ) if resp . StatusCode < 200 || resp . StatusCode > 299 { return fmt . Errorf ( " " , resp . Status ) } b , err := ioutil . ReadAll ( resp . Body ) if err != nil { return err } obj := newObj ( ) if err := json . Unmarshal ( b , obj ) ; err != nil { return err } accumulate ( obj ) link := parseLinks ( resp . Header . Get ( " " ) ) [ " " ] if link == " " { break } u , err := url . Parse ( link ) if err != nil { return fmt . Errorf ( " " , err ) } pagedPath = u . RequestURI ( ) } return nil }
// readPaginatedResultsWithValues is an override that allows control over the query string.
readPaginatedResultsWithValues is an override that allows control over the query string .