diff --git a/handelers/konstanter.go b/handelers/konstanter.go index 9f88f5536a75c8e83ff6b2e0cd9b9f4f5dcfea33..4afe3bec8a7ec74c518f3526d4ad53bf83d4b413 100644 --- a/handelers/konstanter.go +++ b/handelers/konstanter.go @@ -1,6 +1,13 @@ 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 diff --git a/handelers/strukter.go b/handelers/strukter.go index 4a97f3b7335355043d9a556c45e93857bcc01692..9613329106fb2aee464bfbb4044e246aaefc8394 100644 --- a/handelers/strukter.go +++ b/handelers/strukter.go @@ -1,6 +1,5 @@ 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"` diff --git a/main.go b/main.go index ee53077af7a95aaf706dce605bc86e8fcd99ab51..d1d47183c8e3078ecba9331c8dff6af98dfd33e0 100644 --- a/main.go +++ b/main.go @@ -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) }