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
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
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"`
......
......@@ -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)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment