This repository contains the code for the IITK Coin project done so far.
- go version: go1.16.4 linux/amd64
- OS: ubuntu-20.04 LTS
- text editor: VSCode
- terminal: ubuntu terminal
.
├── README.md
├── Handlers
│ └── handler.go
├── sqlite3_func
│ └── sqlite3Func.go
├── utilities
│ └── utilities.go
├── go.mod
├── go.sum
├── Student_info.db
├── main.go
## Usage
```bash
cd $GOPATH/src/github.com/<username>
git clone https://github.com/dhruv354/iitk-coin.git
cd repo
go run main.go
#, or build the program and run the executable
go build
./iitk-coin
Output should look like
created my database
User table created or not altered if already created
user coins table created
Serving at 8080
POST requests take place via JSON
requests. A typical usage would look like
/login
:POST
{"rollno":"<rollno>", "password":"<password>"}
/signup
:POST
{"name":"<username>","rollno":"<user rollno>", "password":"<password>","batch":"<user batch>"}
/logout
:POST
/redeemcoins
:POST
{"coin":"<How much coin want to redeem>", "item":"<item name>"}
/itemredeem
:POST
{"item":"<Id of redeem request>", "coins":"<price of that item>"}
/adminApproval
:POST
{"item":"<Id of redeem request>"}
/addcoins
:POST
{"coins":"<Coins to reward>", "rollno":"<rollno to which coin will be rewarded>"}
/transfercoins
:POST
{"coins":"<Coins to transfer>", "rollno":"<Whom to transfer>"}
GET requests:
/secretpage
:GET
/getcoins
:GET
curl http://localhost:8080/getcoin
- UserData
Name string `json:"name"`
Rollno int `json:"rollno"`
Password string `json:"password"`
Batch int `json:"batch"`
- Claims
Username string `json:"username"`
Rollno int `json:"rollno"`
jwt.StandardClaims
- UserCoins
Rollno int `json:"rollno"`
Coins int `json:"coins"`
- TransferBWUsers
Rollno int `json:"rollno"`
Coins int `json:"coins"`
- ItemRedeem
Item string `json:"item"`
Coins int `json:"coins"`
- RequestId
Id int `json:"id"`