marius/button
go get github.com/mattn/go-sqlite3
go get github.com/gorilla/mux
go get -u github.com/jinzhu/gorm
git clone https://github.com/mariusbld/button.git $GOPATH/src/button
cd $GOPATH/src/button
go install
button
The HTTP server will start with the default port 8080, using a default local SQLite db file at /tmp/button.db
User:
{
"id":20,
"email":"[email protected]",
"first_name":"Jean"
"last_name":"Carter",
"points":100
}
Transfer:
{
"id":19,
"user_id":20,
"amount":1000
}
List all users:
GET /users
Get single user by id:
- If the {id} is not found will return 404
GET /users/{id}
Create user:
- If another user with the same {id} is present will return 500
POST /users
List all transfers for a specified user:
- If the user is not found will return 404
GET /users/{id}/transfers
Create a new transfer
- If the user is not found will return 404
- If there are not enough points, will return 402
POST /users/{id}/transfers
Populate DB with sample test users and transfers:
GET /init-test-data