Skip to content

mariusbld/button

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages