Ruby Webrick
Using docker:
docker run -it -p 8080:8080 ruanbekker/ruby-api
List all items:
$ curl -H 'Content-Type: application/json' -XGET http://localhost:8080/api
{
"items":[]
}
Create Items:
$ curl -H 'Content-Type: application/json' -XPOST http://localhost:8080/api -d '{"name": "spotify", "description": "music streaming service"}'
$ curl -H 'Content-Type: application/json' -XPOST http://localhost:8080/api -d '{"name": "netflix", "description": "tv streaming service"}'
List all items:
$ curl -H 'Content-Type: application/json' -XGET http://localhost:8080/api
{
"items": [
{"id":1,"name":"spotify","description":"music streaming service"},
{"id":2,"name":"netflix","description":"tv streaming service"}
]
}
Update Item:
$ curl -H 'Content-Type: application/json' -XPUT http://localhost:8080/api -d '{"id": 2, "name": "netflix", "description": "tv streaming service..."}'
Delete Item:
$ curl -H 'Content-Type: application/json' -XDELETE http://localhost:8080/api -d '{"id": 2}'
- GET /api
- POST /api, body: {'name': 'james', 'description': 'foobar'}
- UPDATE /api, body: {'id': 1, 'name': 'james', 'description': 'foobar'}
- DELETE /api, body: {'id': 1}