https://github.com/ruanbekker/ruby-webrick-basic-api
Ruby Webrick
https://github.com/ruanbekker/ruby-webrick-basic-api
docker ruby webrick
Last synced: 3 months ago
JSON representation
Ruby Webrick
- Host: GitHub
- URL: https://github.com/ruanbekker/ruby-webrick-basic-api
- Owner: ruanbekker
- Created: 2023-03-20T20:58:10.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-20T22:31:17.000Z (over 3 years ago)
- Last Synced: 2026-03-31T06:33:40.829Z (3 months ago)
- Topics: docker, ruby, webrick
- Language: Ruby
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ruby-webrick-basic-api
Ruby Webrick
## Run the Server
Using docker:
```bash
docker run -it -p 8080:8080 ruanbekker/ruby-api
```
## Make Requests
List all items:
```bash
$ curl -H 'Content-Type: application/json' -XGET http://localhost:8080/api
{
"items":[]
}
```
Create Items:
```bash
$ 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:
```bash
$ 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:
```bash
$ curl -H 'Content-Type: application/json' -XPUT http://localhost:8080/api -d '{"id": 2, "name": "netflix", "description": "tv streaming service..."}'
```
Delete Item:
```bash
$ curl -H 'Content-Type: application/json' -XDELETE http://localhost:8080/api -d '{"id": 2}'
```
## Routes
- GET /api
- POST /api, body: {'name': 'james', 'description': 'foobar'}
- UPDATE /api, body: {'id': 1, 'name': 'james', 'description': 'foobar'}
- DELETE /api, body: {'id': 1}