https://github.com/cenkayla/userbalance
Basic user balance service for learning purposes.
https://github.com/cenkayla/userbalance
go golang pgx postgresql
Last synced: 25 days ago
JSON representation
Basic user balance service for learning purposes.
- Host: GitHub
- URL: https://github.com/cenkayla/userbalance
- Owner: cenkayla
- Created: 2021-07-07T22:02:38.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-07-08T16:58:05.000Z (almost 5 years ago)
- Last Synced: 2025-08-01T01:45:29.955Z (11 months ago)
- Topics: go, golang, pgx, postgresql
- Language: Go
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# User balance service
- Written in Go
- Stores data in PostgreSQL with pgx
# Quickstart
```shell
git clone https://github.com/cenkayla/userbalance.git
cd userbalance
go run cmd/main.go
```
# Usage
To get balance
```shell
$ curl 'localhost:8080/users/balance/1'
```

To add balance
```shell
$ curl --request PUT \
--url "localhost:8080/users/balance/add/1?balance=50" \
--header "Content-Type: application/x-www-form-urlencoded" \
```

To reduce balance
```shell
curl --request PUT \
--url "localhost:8080/users/balance/reduce/1?balance=50" \
--header "Content-Type: application/x-www-form-urlencoded" \
```

To transfer balance
```shell
curl --request PUT \
--url "localhost:8080/users/balance/transfer/1?receiver_id=0&balance=20" \
--header "Content-Type: application/x-www-form-urlencoded" \
```
