Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Cloud - Assignment 2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hans Kristian Hoel
Cloud - Assignment 2
Commits
c97305a2
Commit
c97305a2
authored
Oct 28, 2019
by
Hans Kristian Hoel
Browse files
Options
Downloads
Patches
Plain Diff
set up a lopp so that i get all repositories. working with or without auth
parent
117ec07a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
assignment2/language.go
+23
-3
23 additions, 3 deletions
assignment2/language.go
with
23 additions
and
3 deletions
assignment2/language.go
+
23
−
3
View file @
c97305a2
...
@@ -27,14 +27,34 @@ func HandlerLanguages(w http.ResponseWriter, r *http.Request) {
...
@@ -27,14 +27,34 @@ func HandlerLanguages(w http.ResponseWriter, r *http.Request) {
resp
:=
DoRequest
(
Client
,
w
,
URL3
)
// request link
resp
:=
DoRequest
(
Client
,
w
,
URL3
)
// request link
err
:=
json
.
NewDecoder
(
resp
.
Body
)
.
Decode
(
&
I
)
// decode to I
PageTot
,
err
:=
strconv
.
Atoi
(
resp
.
Header
.
Get
(
"X-Total-Pages"
))
// gets count of total pages
if
err
!=
nil
{
// check for error
if
err
!=
nil
{
// check for error
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusBadRequest
)
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusBadRequest
)
return
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
for
i
:=
range
I
{
// loops true length of I
URL
:=
URL1
+
"/"
+
strconv
.
Itoa
(
I
[
i
]
.
ID
)
+
"/languages"
// creats url for languages with id
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
resp
=
DoRequest
(
Client
,
w
,
URL
)
// request link
...
@@ -57,6 +77,6 @@ func HandlerLanguages(w http.ResponseWriter, r *http.Request) {
...
@@ -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
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
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment