Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
85 lines (60 sloc) 911 Bytes

+++ title = "CRUD Recipe" description = "CRUD (Create, read, update and delete) recipe for Echo" [menu.main] name = "CRUD" parent = "cookbook" +++

Server

server.go

{{< embed "crud/server.go" >}}

Client

curl

Create User

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

Response

{
  "id": 1,
  "name": "Joe Smith"
}

Get User

curl localhost:1323/users/1

Response

{
  "id": 1,
  "name": "Joe Smith"
}

Update User

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

Response

{
  "id": 1,
  "name": "Joe"
}

Delete User

curl -X DELETE localhost:1323/users/1

Response

NoContent - 204

[Source Code]({{< source "crud" >}})

Maintainers