Skip to content

Latest commit

 

History

History
70 lines (65 loc) · 1.19 KB

README.md

File metadata and controls

70 lines (65 loc) · 1.19 KB

marius/button

Install:

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

Run:

button

The HTTP server will start with the default port 8080, using a default local SQLite db file at /tmp/button.db

JSON Format:

User:

{
  "id":20,
  "email":"[email protected]",
  "first_name":"Jean"
  "last_name":"Carter",
  "points":100
}

Transfer:

{
  "id":19,
  "user_id":20,
  "amount":1000
}

Rest API

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

Test API

Populate DB with sample test users and transfers:

GET /init-test-data