Simple Rest API using Golang.
- Docker
- Golang 1.14 or later
- PostgreSQL
make test
- Run docker compose command
make docker-compose
-
Install Golang https://golang.org/dl/
-
Install PostgreSQL https://www.postgresql.org/
-
Change database host on .config.toml file
[database] host = "localhost" ...........
-
Login to postgresql
-
Create database linkaja_test
create database linkaja_test;
-
Run program
make run
-
Check Saldo
Request:
curl -XGET 'http://localhost:8000/account/555001'
Response:
- Success (200)
{ "account_number": 555001, "customer_name": "Bob Martin", "balance": 10000 }
- Data not exists (404)
Account not exists
- Success (200)
-
Transfer
Request:
curl -XPOST -H "Content-type: application/json" -d '{"to_account_number":"555002", "amount":100}' 'localhost:8000/account/555001/transfer'
Response:
- Success (201)
<no content>
- Sender not exists (400)
Sender account not found
- Receiver not exists (400)
Receiver account not found
- Insufficient balance (400)
Insufficient balance
- Success (201)