Skip to content
Snippets Groups Projects
Commit c97305a2 authored by Hans Kristian Hoel's avatar Hans Kristian Hoel
Browse files

set up a lopp so that i get all repositories. working with or without auth

parent 117ec07a
Branches
No related tags found
No related merge requests found
......@@ -27,14 +27,34 @@ func HandlerLanguages(w http.ResponseWriter, r *http.Request) {
resp := DoRequest(Client, w, URL3) // request link
err := json.NewDecoder(resp.Body).Decode(&I) // decode to I
if err != nil { // check for error
PageTot, err := strconv.Atoi(resp.Header.Get("X-Total-Pages")) // gets count of total pages
if err != nil { // check for error
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
for i := 1; i <= PageTot; i++ { // loops true total pages
URL := URL3 + "&page=" + strconv.Itoa(i) // sets url to one page
resp := DoRequest(Client, w, URL)
var TempID []IDLang //creat temp for id
err := json.NewDecoder(resp.Body).Decode(&TempID) // decode to I
if err != nil { // check for error
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
I = append(I, TempID...) // adds test to I
}
for i := range I { // loops true length of I
URL := URL1 + "/" + strconv.Itoa(I[i].ID) + "/languages" // creats url for languages with id
if auth != "false" {
URL = URL + "?private_token=" + auth // adds token to link
}
resp = DoRequest(Client, w, URL) // request link
......@@ -57,6 +77,6 @@ func HandlerLanguages(w http.ResponseWriter, r *http.Request) {
http.Header.Add(w.Header(), "Content-Type", "application/json") // makes the print look good
json.NewEncoder(w).Encode(L)
json.NewEncoder(w).Encode(L) // encode L
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment