github.com/decred/politeia@v1.4.0/politeiawww/legacy/codetracker/github/api/org.go (about) 1 // Copyright (c) 2020 The Decred developers 2 // Use of this source code is governed by an ISC 3 // license that can be found in the LICENSE file. 4 5 package api 6 7 import ( 8 "encoding/json" 9 "fmt" 10 "net/http" 11 ) 12 13 const ( 14 apiOrgReposURL = `https://api.github.com/users/%s/repos?per_page=250` 15 ) 16 17 // FetchOrgRepos requests all repos that are underneath the given organization. 18 func (a *Client) FetchOrgRepos(org string) ([]*Repository, error) { 19 url := fmt.Sprintf(apiOrgReposURL, org) 20 req, err := http.NewRequest("GET", url, nil) 21 if err != nil { 22 return nil, err 23 } 24 25 body, err := a.sendGithubRequest(req) 26 if err != nil { 27 return nil, err 28 } 29 30 var repos []*Repository 31 err = json.Unmarshal(body, &repos) 32 if err != nil { 33 return nil, err 34 } 35 36 return repos, nil 37 }