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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mathilde Hertaas
assignment1
Commits
7df4a6b1
Commit
7df4a6b1
authored
4 months ago
by
Mathilde Hertaas
Browse files
Options
Downloads
Patches
Plain Diff
separated populasion class and added constant class
parent
f6bf6390
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
handelers/konstanter.go
+6
-0
6 additions, 0 deletions
handelers/konstanter.go
handelers/populasjonhandler.go
+0
-39
0 additions, 39 deletions
handelers/populasjonhandler.go
handelers/strukter.go
+28
-0
28 additions, 0 deletions
handelers/strukter.go
with
34 additions
and
39 deletions
handelers/konstanter.go
0 → 100644
+
6
−
0
View file @
7df4a6b1
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
This diff is collapsed.
Click to expand it.
handelers/populasjonhandler.go
+
0
−
39
View file @
7df4a6b1
...
@@ -9,42 +9,6 @@ import (
...
@@ -9,42 +9,6 @@ import (
"strings"
"strings"
)
)
// responsstruktur for befolkningsdata
type
PopulationResponse
struct
{
Error
bool
`json:"error"`
Msg
string
`json:"msg"`
Data
[]
Country
`json:"data"`
}
// land og dens befolkningsdata
type
Country
struct
{
Name
string
`json:"country"`
Code
string
`json:"iso3"`
// Trebokstavskode (ISO 3166-1 alpha-3)
PopulationCounts
[]
PopulationCount
`json:"populationCounts"`
}
// befolkningsdate for et bestemt år (brukes i den endelige repsonsen under values)
type
PopulationCount
struct
{
Year
int
`json:"year"`
Value
int
`json:"value"`
}
// Responsstruktur for vårt API(det som vises på skjerm)
type
PopulationAPIResponse
struct
{
Name
string
`json:"land"`
Gjennomsnitt
int
`json:"gjennomsnittlig populasjon"`
Values
[]
PopulationCount
`json:"årlige populasjoner"`
}
// ISO 3166-1 alpha-2 til alpha-3 landkoder
// ISO 3166-1 alpha-2 til alpha-3 landkoder
var
isoAlpha2ToAlpha3
=
make
(
map
[
string
]
string
)
var
isoAlpha2ToAlpha3
=
make
(
map
[
string
]
string
)
...
@@ -129,9 +93,6 @@ func getPopulationForCountry(alpha2Code string, startYear, endYear int) (*Popula
...
@@ -129,9 +93,6 @@ func getPopulationForCountry(alpha2Code string, startYear, endYear int) (*Popula
},
nil
},
nil
}
}
func
PopulationHandler
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
PopulationHandler
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
// r.URL.Path er den fulle URL som ble sendt til serveren altså /population/NO
// r.URL.Path er den fulle URL som ble sendt til serveren altså /population/NO
// deretter fjerner den /population/ så vi sitter igjen med NO
// deretter fjerner den /population/ så vi sitter igjen med NO
...
...
This diff is collapsed.
Click to expand it.
handelers/strukter.go
+
28
−
0
View file @
7df4a6b1
...
@@ -35,3 +35,31 @@ type CombinedInfo struct {
...
@@ -35,3 +35,31 @@ type CombinedInfo struct {
Capital
string
`json:"capital"`
Capital
string
`json:"capital"`
Cities
string
`json:"cities"`
Cities
string
`json:"cities"`
}
}
// responsstruktur for befolkningsdata
type
PopulationResponse
struct
{
Error
bool
`json:"error"`
Msg
string
`json:"msg"`
Data
[]
Country
`json:"data"`
}
// land og dens befolkningsdata
type
Country
struct
{
Name
string
`json:"country"`
Code
string
`json:"iso3"`
// Trebokstavskode (ISO 3166-1 alpha-3)
PopulationCounts
[]
PopulationCount
`json:"populationCounts"`
}
// befolkningsdate for et bestemt år (brukes i den endelige repsonsen under values)
type
PopulationCount
struct
{
Year
int
`json:"year"`
Value
int
`json:"value"`
}
// Responsstruktur for vårt API(det som vises på skjerm)
type
PopulationAPIResponse
struct
{
Name
string
`json:"land"`
Gjennomsnitt
int
`json:"gjennomsnittlig populasjon"`
Values
[]
PopulationCount
`json:"årlige populasjoner"`
}
\ 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