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

more commenting on code, and fixed auth for language

parent 6f355598
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ func HandlerCommits(w http.ResponseWriter, r *http.Request) { ...@@ -26,7 +26,7 @@ func HandlerCommits(w http.ResponseWriter, r *http.Request) {
C.Auth = true // sets auth to true 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 resp := DoRequest(Client, w, URL3) //request the /prodjects link with 100 repositoris per page
......
...@@ -12,29 +12,35 @@ func HandlerLanguages(w http.ResponseWriter, r *http.Request) { ...@@ -12,29 +12,35 @@ func HandlerLanguages(w http.ResponseWriter, r *http.Request) {
var I []IDLang var I []IDLang
var L Language 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 Client := http.DefaultClient
auth := QueryGet("auth", "false", r) URL3 := URL1 + "?per_page=100"
if auth != "false" {
L.Auth = true 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) err := json.NewDecoder(resp.Body).Decode(&I) // decode to I
if err != nil { if err != nil { // check for error
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return return
} }
for i := range I { for i := range I { // loops true length of I
URL := URL1 + "/" + strconv.Itoa(I[i].ID) + "/languages" 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) err = json.NewDecoder(resp.Body).Decode(&L.Languages) // decode to language
if err != nil { if err != nil { // check for error
http.Error(w, err.Error(), http.StatusBadRequest)
return return
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment