This project is an API using the Go programming language.
- Docker and Docker Compose installed.
- GoLang version 1.14.10
- Web router gin-gonic/gin
- Clean Architecture Concept
- Project Layout
The essential commands are provided from the Makefile.
To run the project tests you can use the command test
. For example:
make test
So to run the project in localhost as a development mode you can use the command start
make start
The start
will up the http server in your machine in localhost:3000
make build
- build the image dockermake lint
- runs Go lintersmake bash
- open the container bashmake restart
- restart the docker compose and containersmake stop
- stop the containersmake clean
- stop containers and clean the environmentmake logs [tail=50]
- show the logs (tail is optional, the default value is 100)
This chapter show about how to use the API interface. We'll use the curl tool to show the examples.
Send a request to /accounts
with the POST
verb.
For example:
curl -X POST \
localhost:3000/accounts \
-d '{
"account_id": 1,
"document_number": "12345678900",
"available_credit_limit": 1000
}'
Response:
{
"account_id": "1",
"document_number": "12345678900",
"available_credit_limit": 1000
}
Send a request to /accounts/:accountId
with the GET
verb, passing the accountId
as account identifier.
For example:
curl localhost:3000/accounts/1
Response:
{
"account_id": 1,
"document_number": "12345678900",
"available_credit_limit": 1000
}
Send a request to /transactions
with the POST
verb.
For example:
curl -X POST \
localhost:3000/transactions \
-d '{
"account_id": 1,
"operation_type_id": 4,
"amount": 123.45
}'
Send a request to /transactions
with the GET
verb.
For example:
curl localhost:3000/transactions