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

Have set up Auth. Som you can get repositories with or with out auth

parent 995d10f7
Branches main
No related tags found
No related merge requests found
...@@ -45,10 +45,18 @@ func HandlerCommits(w http.ResponseWriter, r *http.Request) { ...@@ -45,10 +45,18 @@ func HandlerCommits(w http.ResponseWriter, r *http.Request) {
var I []IDS var I []IDS
var C Commits var C Commits
APIURL := "https://git.gvk.idi.ntnu.no/api/v4/projects" URL1 := "https://git.gvk.idi.ntnu.no/api/v4/projects"
URL2 := "https://git.gvk.idi.ntnu.no/api/v4/projects?private_token="
Client := http.DefaultClient Client := http.DefaultClient
APIURL := URL1
// auth := QueryGet("auth", "false", r) auth := QueryGet("auth", "false", r)
if auth != "false" {
APIURL = URL2 + auth
C.Auth = true
}
fmt.Println(auth)
fmt.Println(APIURL)
resp := DoRequest(Client, w, APIURL) resp := DoRequest(Client, w, APIURL)
...@@ -67,7 +75,10 @@ func HandlerCommits(w http.ResponseWriter, r *http.Request) { ...@@ -67,7 +75,10 @@ func HandlerCommits(w http.ResponseWriter, r *http.Request) {
} }
for i := range I { for i := range I {
URL := APIURL + "/" + strconv.Itoa(I[i].ID) + "/repository/commits" URL := URL1 + "/" + strconv.Itoa(I[i].ID) + "/repository/commits"
if auth != "false" {
URL = URL + "?private_token=" + auth
}
resp = DoRequest(Client, w, URL) resp = DoRequest(Client, w, URL)
...@@ -89,7 +100,6 @@ func HandlerCommits(w http.ResponseWriter, r *http.Request) { ...@@ -89,7 +100,6 @@ func HandlerCommits(w http.ResponseWriter, r *http.Request) {
limit := QueryGet("limit", "5", r) limit := QueryGet("limit", "5", r)
fmt.Println(limit)
TempInt, err := strconv.Atoi(limit) TempInt, err := strconv.Atoi(limit)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment