CRUD Recipe

Server

server.go

  1.  

Client

curl

Create User

  1. curl -X POST \
  2. -H 'Content-Type: application/json' \
  3. -d '{"name":"Joe Smith"}' \
  4. localhost:1323/users

Response

  1. {
  2. "id": 1,
  3. "name": "Joe Smith"
  4. }

Get User

  1. curl localhost:1323/users/1

Response

  1. {
  2. "id": 1,
  3. "name": "Joe Smith"
  4. }

Update User

  1. curl -X PUT \
  2. -H 'Content-Type: application/json' \
  3. -d '{"name":"Joe"}' \
  4. localhost:1323/users/1

Response

  1. {
  2. "id": 1,
  3. "name": "Joe"
  4. }

Delete User

  1. curl -X DELETE localhost:1323/users/1

Response

NoContent - 204

Source Code

Maintainers