Created
September 25, 2020 13:36
-
-
Save didil/e5aa54247b1d529bad332fc4d6a49d4a to your computer and use it in GitHub Desktop.
Locations service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BuildRouter builds the router | |
func BuildRouter() (*chi.Mux, error) { | |
r := chi.NewRouter() | |
// the single route in our app (would need to be moved to a "handlers" package in a production app) | |
r.Get("/all", func(w http.ResponseWriter, r *http.Request) { | |
locations := []Location{ | |
Location{ | |
ID: 1, | |
Name: "London", | |
Country: "UK", | |
}, | |
Location{ | |
ID: 2, | |
Name: "Paris", | |
Country: "FR", | |
}, | |
} | |
jsonOk(w, &locations) | |
}) | |
return r, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment