Skip to content

Instantly share code, notes, and snippets.

@didil
Created September 25, 2020 13:36
Show Gist options
  • Save didil/e5aa54247b1d529bad332fc4d6a49d4a to your computer and use it in GitHub Desktop.
Save didil/e5aa54247b1d529bad332fc4d6a49d4a to your computer and use it in GitHub Desktop.
Locations service
// 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