Stateless HTTP API that validates Snake game moves.
make run
# custom port/secret
./bin/snake-validator --port 8080 --secret my-secretGET /new?w=10&h=10 — Start a new game. Returns initial state with a random fruit.
POST /validate — Validate a tick sequence. Returns updated state on success.
{
"gameId": "...", "width": 10, "height": 10, "score": 0,
"fruit": { "x": 3, "y": 4 },
"snake": { "x": 0, "y": 0, "velX": 1, "velY": 0 },
"ticks": [{ "velX": 1, "velY": 0 }]
}| Status | Meaning |
|---|---|
| 200 | Valid — returns new state |
| 400 | Invalid request or tampered state |
| 404 | Ticks did not reach the fruit |
| 405 | Wrong HTTP method |
| 418 | Invalid move or out of bounds |
| 500 | Internal error |
make test
make lint