diff --git a/assignment2/commit.go b/assignment2/commit.go index 625205f60fb88f3f528e7186090414c24495b316..c27774eb35d4351d463164ea46fea32ff2aad498 100644 --- a/assignment2/commit.go +++ b/assignment2/commit.go @@ -26,7 +26,7 @@ func HandlerCommits(w http.ResponseWriter, r *http.Request) { C.Auth = true // sets auth to true } - fmt.Println(URL3) + fmt.Println(URL3) // ************************************************** resp := DoRequest(Client, w, URL3) //request the /prodjects link with 100 repositoris per page diff --git a/assignment2/language.go b/assignment2/language.go index 06422a8ac261bf94031da27ebd8b04516229a375..6d020c27bb65751488fb6d76acd89908a69b546b 100644 --- a/assignment2/language.go +++ b/assignment2/language.go @@ -12,29 +12,35 @@ func HandlerLanguages(w http.ResponseWriter, r *http.Request) { var I []IDLang var L Language - URL1 := "https://git.gvk.idi.ntnu.no/api/v4/projects" + URL1 := "https://git.gvk.idi.ntnu.no/api/v4/projects" // main url + URL2 := "https://git.gvk.idi.ntnu.no/api/v4/projects?private_token=" // url for token Client := http.DefaultClient - auth := QueryGet("auth", "false", r) - if auth != "false" { - L.Auth = true + URL3 := URL1 + "?per_page=100" + + auth := QueryGet("auth", "false", r) // gets auth from localhost link + if auth != "false" { // check ig auth is not false + L.Auth = true // sets auth to true + URL3 = URL2 + auth + "?per_page=100" + } - resp := DoRequest(Client, w, URL1) + resp := DoRequest(Client, w, URL3) // request link - err := json.NewDecoder(resp.Body).Decode(&I) - if err != nil { + err := json.NewDecoder(resp.Body).Decode(&I) // decode to I + if err != nil { // check for error http.Error(w, err.Error(), http.StatusBadRequest) return } - for i := range I { - URL := URL1 + "/" + strconv.Itoa(I[i].ID) + "/languages" + for i := range I { // loops true length of I + URL := URL1 + "/" + strconv.Itoa(I[i].ID) + "/languages" // creats url for languages with id - resp = DoRequest(Client, w, URL) + resp = DoRequest(Client, w, URL) // request link - err = json.NewDecoder(resp.Body).Decode(&L.Languages) - if err != nil { + err = json.NewDecoder(resp.Body).Decode(&L.Languages) // decode to language + if err != nil { // check for error + http.Error(w, err.Error(), http.StatusBadRequest) return }