Skip to content

Instantly share code, notes, and snippets.

@Duncanian
Created May 31, 2019 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Duncanian/f7553b66d643e1250fbe89b7891d3bc8 to your computer and use it in GitHub Desktop.
Save Duncanian/f7553b66d643e1250fbe89b7891d3bc8 to your computer and use it in GitHub Desktop.
Handling the endpoint for getting a single event in go-rest-api
func getOneEvent(w http.ResponseWriter, r *http.Request) {
eventID := mux.Vars(r)["id"]
for _, singleEvent := range events {
if singleEvent.ID == eventID {
json.NewEncoder(w).Encode(singleEvent)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment