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
27e1fc7c
Commit
27e1fc7c
authored
5 years ago
by
Hans Kristian Hoel
Browse files
Options
Downloads
Patches
Plain Diff
setting up some structs and starting on handlers
parent
be1b9ee3
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
assignment2/cmd/main.go
+3
-2
3 additions, 2 deletions
assignment2/cmd/main.go
assignment2/handler.go
+33
-0
33 additions, 0 deletions
assignment2/handler.go
assignment2/structs.go
+14
-2
14 additions, 2 deletions
assignment2/structs.go
with
50 additions
and
4 deletions
assignment2/cmd/main.go
+
3
−
2
View file @
27e1fc7c
...
...
@@ -20,6 +20,7 @@ func main() {
http
.
HandleFunc
(
"/repocheck/v1/languages"
,
assignment2
.
HandlerLanguages
)
// runs handelr function
http
.
HandleFunc
(
"/repocheck/v1/issues"
,
assignment2
.
HandlerIssues
)
// runs handelr function
http
.
HandleFunc
(
"/repocheck/v1/status"
,
assignment2
.
HandlerStatus
)
// runs handelr function
http
.
HandleFunc
(
"/repocheck/v1/webhooks"
,
assignment2
.
HandlerWebhooks
)
// runs handelr function
fmt
.
Println
(
"Listening on port "
+
port
)
log
.
Fatal
(
http
.
ListenAndServe
(
":"
+
port
,
nil
))
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
assignment2/handler.go
+
33
−
0
View file @
27e1fc7c
...
...
@@ -12,17 +12,50 @@ func HandlerNil(w http.ResponseWriter, r *http.Request) { //standar default res
func
HandlerCommits
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
limit
:=
r
.
URL
.
Query
()
.
Get
(
"limit"
)
// Reads limit
if
limit
==
""
{
// cheks if there exist an limit
limit
=
"5"
// sets limit to 5
}
auth
:=
r
.
URL
.
Query
()
.
Get
(
"auth"
)
// Reads auth
if
auth
==
""
{
// cheks if there exist an auth
auth
=
"false"
// sets auth to false
}
}
func
HandlerLanguages
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
limit
:=
r
.
URL
.
Query
()
.
Get
(
"limit"
)
// Reads limit
if
limit
==
""
{
// cheks if there exist an limit
limit
=
"5"
// sets limit to 5
}
auth
:=
r
.
URL
.
Query
()
.
Get
(
"auth"
)
// Reads auth
if
auth
==
""
{
// cheks if there exist an auth
auth
=
"false"
// sets auth to false
}
}
func
HandlerIssues
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
types
:=
r
.
URL
.
Query
()
.
Get
(
"type"
)
if
types
==
""
{
// error
}
auth
:=
r
.
URL
.
Query
()
.
Get
(
"auth"
)
// Reads auth
if
auth
==
""
{
// cheks if there exist an auth
auth
=
"false"
// sets auth to false
}
}
func
HandlerStatus
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
}
func
HandlerWebhooks
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
assignment2/structs.go
+
14
−
2
View file @
27e1fc7c
...
...
@@ -3,3 +3,15 @@ package assignment2
import
(
)
type
Language
struct
{
Languages
[]
string
`json:"lagnguages"`
Auth
string
`json:"auth2`
}
type
Status
struct
{
Gitlab
int
`json:"gitlab"`
Database
int
`json:"database"`
Uptime
int
`json:"uptime"`
Version
string
`json:"version"`
}
\ No newline at end of file
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