Skip to content
Snippets Groups Projects
Commit c1c7aa02 authored by Mathilde Hertaas's avatar Mathilde Hertaas
Browse files

added constant to main class urls

parent 7df4a6b1
No related branches found
No related tags found
No related merge requests found
package handelers package handelers
const HOMEPAGE_DEFAULT = "http://localhost:8080/" //url til hjemmeside //URL
const INFO_DEFAULT = "http://localhost:8080/countryinfo/vi/info/" // url info for brukerspesifikasjon const HOMEPAGE_DEFAULT = "http://localhost:8080"
const POPULATION_DEFAULT = "" const INFO_DEFAULT = "/countryinfo/vi/info/"
const STATUS_DEFAULT = "" const POPULATION_DEFAULT = "/population/"
\ No newline at end of file const STATUS_DEFAULT = "/status/"
const SLASH_DEFAULT = "/"
//ERRORS
//Terminal info
const RUNNING_ON_PORT = ""
\ No newline at end of file
package handelers package handelers
type Flags struct{ type Flags struct{
PNG string `json:"png"` PNG string `json:"png"`
} }
...@@ -19,12 +18,11 @@ type CountryInfo struct { ...@@ -19,12 +18,11 @@ type CountryInfo struct {
Flags Flags `json:"flags"` Flags Flags `json:"flags"`
} }
type CityInfo struct { //type CityInfo struct {
Cities []string `json:"cities"` // Cities []string `json:"cities"`
} //}
// Struktur for kombinert respons // Struktur for kombinert respons i info
type CombinedInfo struct { type CombinedInfo struct {
Name string `json:"name"` Name string `json:"name"`
Continents []string `json:"continenents"` Continents []string `json:"continenents"`
......
...@@ -9,19 +9,17 @@ import ( ...@@ -9,19 +9,17 @@ import (
var serviceStartTime time.Time var serviceStartTime time.Time
func main() { func main() {
serviceStartTime = time.Now() 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) handelers.DiagnosticsHandler(w, r, serviceStartTime)
}) })
http.HandleFunc("/", handelers.HomeHandler) http.HandleFunc(handelers.SLASH_DEFAULT, handelers.HomeHandler)
http.HandleFunc("/countryinfo/v1/info/", handelers.CountryInfoHandler) http.HandleFunc(handelers.INFO_DEFAULT, handelers.CountryInfoHandler)
http.HandleFunc("/population/", handelers.PopulationHandler) http.HandleFunc(handelers.POPULATION_DEFAULT, handelers.PopulationHandler)
fmt.Println("Server running on port 8080...")
if err := http.ListenAndServe(":8080", nil); err != nil { if err := http.ListenAndServe(":8080", nil); err != nil {
fmt.Printf("Server failed to start: %s\n", err) fmt.Printf("Server failed to start: %s\n", err)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment