For sake of simplicity the project uses sqlite3
as db and a very basic ui.
docker build . -t gymshark
docker run -p 8081:8081 gymshark
docker compose up -d
To run the server locally you need to have go
and sqlite3
installed.
- Start server locally:
go run main.go
-
Check Health of the API by going to http://0.0.0.0:8081/health. You should see a response "OK"
-
The UI is available at http://0.0.0.0:8081/
go test ./...
For simplicity all previous pack sizes are removed. In a production scenario we would need to update them by a unique identifier.
curl -X POST -H "Content-Type: application/json" -d '{"packSizes":[250,500,1000,2000,5000]}' http://localhost:8081/api/save-pack-sizes
Response:
{"success":true,"msg":"Created"}
curl http://localhost:8081/api/pack-sizes
Response:
{
"packSizes": [
250,
500,
1000,
2000,
5000
]
}
curl http://localhost:8081/api/packs/12001
Response:
{
"packs": [
{
"qty": 1,
"items_per_unit": 2000
},
{
"qty": 2,
"items_per_unit": 5000
},
{
"qty": 1,
"items_per_unit": 250
}
]
}