Skip to content

Latest commit

 

History

History
65 lines (52 loc) · 979 Bytes

File metadata and controls

65 lines (52 loc) · 979 Bytes

Statistics API

Template for a lightweight PHP micro-service to record and expose per-country usage statistics.

Getting Started

Build containers, install PHP dependencies, and start the stack:

make up

Endpoints

Update Statistics

curl -X POST http://127.0.0.1:8088/v1/statistics \
     -H "Content-Type: application/json" \
     -d '{"countryCode": "ru"}'

Response:

201 Created

Wrong country code example:

curl -X POST http://127.0.0.1:8088/v1/statistics \
     -H "Content-Type: application/json" \
     -d '{"countryCode": "wrongCountry"}'

Response:

201 Created

Get Country Statistics

curl -X GET http://127.0.0.1:8088/v1/statistics \
     -H "Content-Type: application/json"

Response:

{
  "ru": 813,
  "us": 456,
  "it": 92,
  "de": 17,
  "cy": 123
}

Run Unit Tests

Execute the full PHPUnit suite:

make unit-test

Run Load Tests

make load-test