Request:
curl --request GET \
--url http://localhost:8080/game/new
Answer:
{
"body": {
"game_id": "5c9f0611fa5ff0ad9ea97e9c69692bd20ee8d1fc"
},
"code": 0,
"msg": "ok"
}
Request:
curl --request POST \
--url http://localhost:8080/game/play \
--header 'content-type: application/json' \
--data '{
"game_id": "5c9f0611fa5ff0ad9ea97e9c69692bd20ee8d1fc",
"guess": ["BLUE", "PURPLE", "RED", "YELLOW"]
}
'
Answer:
{
"body": {
"black_pegs": 1,
"white_pegs": 1
},
"code": 0,
"msg": "ok"
}
Request:
curl --request GET \
--url http://localhost:8080/game/history \
--header 'content-type: application/json' \
--data '{
"game_id": "5c9f0611fa5ff0ad9ea97e9c69692bd20ee8d1fc"
}
'
Answer:
{
"body": [
{
"guess": [
"BLUE",
"PURPLE",
"RED",
"YELLOW"
],
"result": {
"black_pegs": 1,
"white_pegs": 1
}
}
],
"code": 0,
"msg": "ok"
}
Before booting up the application you must run the MySQL container so it can create the database:
docker-compose up --build mysql
Otherwise you can just boot up the full stack twice and let the other containers fail:
docker-compose up --build
In the folder examples there's a python script which creates a new game, tries 5 random guesses, and asks for the game historic. To execute it, the Requests library must be installed.
python examples/example.py