Skip to content

Commit

Permalink
add adding id
Browse files Browse the repository at this point in the history
  • Loading branch information
gagarinfan committed Dec 20, 2018
1 parent 9e33fc5 commit 90c553d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion SQL4/sqljson.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func main() {
router := mux.NewRouter()
router.HandleFunc("/people", GetPeopleEndpoint).Methods("GET")
router.HandleFunc("/people/{id}", GetPersonEndpoint).Methods("GET")
router.HandleFunc("/people/{id}", CreatePersonEndpoint).Methods("POST")
router.HandleFunc("/people/{id}+{name}+{location}", CreatePersonEndpoint).Methods("POST")
router.HandleFunc("/people/{id}", DeletePersonEndpoint).Methods("DELETE")
log.Fatal(http.ListenAndServe(":8000", router))

Expand Down Expand Up @@ -228,6 +228,8 @@ func CreatePersonEndpoint(w http.ResponseWriter, r *http.Request) {
var person Person
_ = json.NewDecoder(r.Body).Decode(&person)
person.ID = params["id"]
person.Name = params["name"]
person.Location = params["location"]
people = append(people, person)
json.NewEncoder(w).Encode(people)
}
Expand Down

0 comments on commit 90c553d

Please sign in to comment.