api
provides several statuses with the intention of returning specific http responses, the http responses need to be implemented- Unit testing of
api
was lighter than I would have liked - Took a few shortcuts with
microhttpd
which I suspect might have some memory repercussions, but I'm not sure - The
parser
is very rigid, it would be nice to use a library likejson-c
instead - Ideally, the
store
module would be a dynamically allocated linked-list - Add
DELETE
support - there is some consideration instore
for this, but it's primitive - Add
PUT
for update support
Query a terminal
GET /terminals/1
{
"id": 1,
"cardType": [ "Visa", "EFTPOS" ],
"TransactionType": [ "Cheque", "Savings" ]
}
Query all terminals
GET /terminals
{
"terminals":
[
{
"id": 0,
"cardType": [ "Visa", "MasterCard", "EFTPOS" ],
"TransactionType": [ "Cheque", "Savings", "Credit" ]
},
{
"id": 1,
"cardType": [ "Visa", "EFTPOS" ],
"TransactionType": [ "Cheque", "Savings" ]
},
//...
]
}
To Add a terminal
POST /terminals '{"cardType": ["visa", "MasterCard"], "TransactionType": ["Cheque"]}'
The result will be the terminal id:
0
curl -X GET -H "Accept: application/json" localhost:11337/terminals
curl -X POST -H "Accept: application/json" --data '{"cardType": ["visa", "MasterCard"], "TransactionType": ["Cheque"]}' localhost:11337/terminals
On Mac:
brew install libmicrohttpd
On Ubuntu:
sudo apt install libmicrohttpd
On Windows: ???
mkdir build
cd build
cmake ..
cmake --build .
Install the CMake Tools extension and use the little blue bar at the bottom of the window ;)
Acceptance tests are run as a bash script. In one terminal execute the program:
./build/App
In another terminal, execute the tests:
./acceptance/acceptance.sh
Unit tests can be run after a build:
./build/test/tests/Test