This is a simple service for keeping live scores. It has HTTP based API, which allows to:
- add games
- update scores
- request score results
The service is using Vert.x 3.
The API can be accessed using HTTP. The different requests are described below.
- URL:
api/v1.0/scores
- Method:
POST
- Request body:
{
"homeTeam": "Aston Villa",
"awayTeam": "Preston North End",
"startTime": "14th January 2017, 17:30"
}
In case of success:
- HTTP
200
- Response body:
{
"awayTeam": "Preston North End",
"awayTeamGoals": 0,
"gameTime": "0",
"homeTeam": "Aston Villa",
"homeTeamGoals": 0,
"startTime": "Saturday 14th January 2017, 17:30"
}
In case of problems:
- HTTP
400
- Response body:
{
"error": "<Error message>"
}
- URL:
api/v1.0/scores
- Method:
PUT
- Request body:
{
"homeTeam": "Aston Villa",
"awayTeam": "Preston North End",
"homeTeamGoals": 1,
"awayTeamGoals": 0,
"gameTime": "HT"
}
In case of success:
- HTTP
200
- Response body:
{
"awayTeam": "Preston North End",
"awayTeamGoals": 1,
"gameTime": "HT",
"homeTeam": "Aston Villa",
"homeTeamGoals": 0,
"startTime": "Saturday 14th January 2017, 17:30"
}
In case of problems:
- HTTP
400
- Response body:
{
"error": "<Error message>"
}
- URL:
api/v1.0/scores
- Method:
GET
- Request body: Empty
In case of success:
- HTTP
200
- Response body:
[
{
"awayTeam": "Preston North End",
"awayTeamGoals": 1,
"gameTime": "HT",
"homeTeam": "Aston Villa",
"homeTeamGoals": 0,
"startTime": "Saturday 14th January 2017, 17:30"
}
]
You can use the qpid-send and qpid-receive utilities from Apache Qpid project to communicate with the service from the command line:
- Create a new game
curl -X POST --data '{ "homeTeam": "Aston Villa", "awayTeam": "Preston North End", "startTime": "14th January 2017, 17:30" }' http://localhost:8080/api/v1.0/scores
- Update the score
curl -X PUT --data '{ "homeTeam": "Aston Villa", "awayTeam": "Preston North End", "homeTeamGoals": 1, "awayTeamGoals": 0, "gameTime": "HT"}' http://localhost:8080/api/v1.0/scores
- Get scores
curl -X GET --data '' http://localhost:8080/api/v1.0/scores
The Kubernetes
directory contains YAML files which can be used for deployment into Kubernetes cluster. Use the kubectl
utility to deploy it.
kubectl create -f config.yaml
kubectl create -f deployment.yaml