1
0
mirror of https://github.com/labstack/echo.git synced 2025-01-10 00:28:23 +02:00
echo/website/content/recipes/crud.md
Vishal Rana f4b0004d2b website/recipe in the main repo
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-10-20 09:11:07 -07:00

991 B

+++ title = "CRUD Recipe" description = "CRUD (Create, read, update and delete) recipe / example for Echo" [menu.side] name = "CRUD" parent = "recipes" weight = 2 +++

CRUD (Create, read, update and delete) Recipe

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

Maintainers

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