diff --git a/handelers/konstanter.go b/handelers/konstanter.go new file mode 100644 index 0000000000000000000000000000000000000000..9f88f5536a75c8e83ff6b2e0cd9b9f4f5dcfea33 --- /dev/null +++ b/handelers/konstanter.go @@ -0,0 +1,6 @@ +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 diff --git a/handelers/populasjonhandler.go b/handelers/populasjonhandler.go index b81780c463e90d4cd5a4d8ed8ef638d9b655df48..afc7abda6e44d6589314169a47d6e37a8ce2a327 100644 --- a/handelers/populasjonhandler.go +++ b/handelers/populasjonhandler.go @@ -9,42 +9,6 @@ import ( "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 var isoAlpha2ToAlpha3 = make(map[string]string) @@ -129,9 +93,6 @@ func getPopulationForCountry(alpha2Code string, startYear, endYear int) (*Popula }, nil } - - - func PopulationHandler(w http.ResponseWriter, r *http.Request) { // 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 diff --git a/handelers/strukter.go b/handelers/strukter.go index 69a56af612bb0402c9fd2ae2f58237a7acf22519..4a97f3b7335355043d9a556c45e93857bcc01692 100644 --- a/handelers/strukter.go +++ b/handelers/strukter.go @@ -34,4 +34,32 @@ type CombinedInfo struct { Flags string `json:"flags"` Capital string `json:"capital"` 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