Skip to content

LiveScore service demo with HTTP based API using Vert.x

Notifications You must be signed in to change notification settings

CaliaLove/livescore-demo-vertx-http

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

LiveScore service demo with Vert.x and HTTP/REST API

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.

API

The API can be accessed using HTTP. The different requests are described below.

Add new game

Request

  • URL: api/v1.0/scores
  • Method:POST
  • Request body:
{
  "homeTeam": "Aston Villa",
  "awayTeam": "Preston North End",
  "startTime": "14th January 2017, 17:30"
}

Response

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>"
}

Update game score

Request

  • URL: api/v1.0/scores
  • Method:PUT
  • Request body:
{
  "homeTeam": "Aston Villa",
  "awayTeam": "Preston North End",
  "homeTeamGoals": 1,
  "awayTeamGoals": 0,
  "gameTime": "HT"
}

Response

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>"
}

Get game scores

Request

  • URL: api/v1.0/scores
  • Method:GET
  • Request body: Empty

Response

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"
  }
]

API Examples

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

Kubernetes deployment

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

About

LiveScore service demo with HTTP based API using Vert.x

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 92.6%
  • Shell 7.4%