Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
assignment1
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mathilde Hertaas
assignment1
Commits
c1c7aa02
Commit
c1c7aa02
authored
3 months ago
by
Mathilde Hertaas
Browse files
Options
Downloads
Patches
Plain Diff
added constant to main class urls
parent
7df4a6b1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
handelers/konstanter.go
+11
-4
11 additions, 4 deletions
handelers/konstanter.go
handelers/strukter.go
+4
-6
4 additions, 6 deletions
handelers/strukter.go
main.go
+4
-6
4 additions, 6 deletions
main.go
with
19 additions
and
16 deletions
handelers/konstanter.go
+
11
−
4
View file @
c1c7aa02
package
handelers
const
HOMEPAGE_DEFAULT
=
"http://localhost:8080/"
//url til hjemmeside
const
INFO_DEFAULT
=
"http://localhost:8080/countryinfo/vi/info/"
// url info for brukerspesifikasjon
const
POPULATION_DEFAULT
=
""
const
STATUS_DEFAULT
=
""
\ No newline at end of file
//URL
const
HOMEPAGE_DEFAULT
=
"http://localhost:8080"
const
INFO_DEFAULT
=
"/countryinfo/vi/info/"
const
POPULATION_DEFAULT
=
"/population/"
const
STATUS_DEFAULT
=
"/status/"
const
SLASH_DEFAULT
=
"/"
//ERRORS
//Terminal info
const
RUNNING_ON_PORT
=
""
\ No newline at end of file
This diff is collapsed.
Click to expand it.
handelers/strukter.go
+
4
−
6
View file @
c1c7aa02
package
handelers
type
Flags
struct
{
PNG
string
`json:"png"`
}
...
...
@@ -19,12 +18,11 @@ type CountryInfo struct {
Flags
Flags
`json:"flags"`
}
type
CityInfo
struct
{
Cities
[]
string
`json:"cities"`
}
//type CityInfo struct {
// Cities []string `json:"cities"`
//}
// Struktur for kombinert respons
// Struktur for kombinert respons
i info
type
CombinedInfo
struct
{
Name
string
`json:"name"`
Continents
[]
string
`json:"continenents"`
...
...
This diff is collapsed.
Click to expand it.
main.go
+
4
−
6
View file @
c1c7aa02
...
...
@@ -9,19 +9,17 @@ import (
var
serviceStartTime
time
.
Time
func
main
()
{
serviceStartTime
=
time
.
Now
()
http
.
HandleFunc
(
"/status/"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
http
.
HandleFunc
(
handelers
.
STATUS_DEFAULT
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
handelers
.
DiagnosticsHandler
(
w
,
r
,
serviceStartTime
)
})
http
.
HandleFunc
(
"/"
,
handelers
.
HomeHandler
)
http
.
HandleFunc
(
"/countryinfo/v1/info/"
,
handelers
.
CountryInfoHandler
)
http
.
HandleFunc
(
"/population/"
,
handelers
.
PopulationHandler
)
http
.
HandleFunc
(
handelers
.
SLASH_DEFAULT
,
handelers
.
HomeHandler
)
http
.
HandleFunc
(
handelers
.
INFO_DEFAULT
,
handelers
.
CountryInfoHandler
)
http
.
HandleFunc
(
handelers
.
POPULATION_DEFAULT
,
handelers
.
PopulationHandler
)
fmt
.
Println
(
"Server running on port 8080..."
)
if
err
:=
http
.
ListenAndServe
(
":8080"
,
nil
);
err
!=
nil
{
fmt
.
Printf
(
"Server failed to start: %s
\n
"
,
err
)
}
...
...
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