Skip to main content

Quick start

Docker image

Run the server in Docker and connect to an existing database

# connect to postgres
docker run -p 3000:3000 restgo/rest -db.url "postgres://user:passwd@localhost:5432/db"

# connect to mysql
docker run -p 3000:3000 restgo/rest -db.url "mysql://user:passwd@tcp(127.0.0.1:3306)/db_name"

# connect to sqlite file with volume
docker run -p 3000:3000 -v $(pwd):/data restgo/rest -db.url "sqlite:///data/my.db"

Use API

Assume there is a todos table in the database with id, title and done fields, the RESTFul CURD API is auto-generated for the table.

Create a todo item

curl -XPOST "localhost:3000/todos" -d '{"title": "setup api server", "done": false}'

Read

curl -XGET "localhost:3000/todos/1"

Update

curl -XPUT "localhost:3000/todos/1" -d '{"title": "setup api server", "done": true}'

Delete

curl -XDELETE "localhost:3000/todos/1"

What's Next