The Election Spring Boot RESTful Web Service, backed by MongoDB, and uses RabbitMQ for IPC
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.idea
gradle/wrapper
scripts
src
.gitignore
.travis.yml
Dockerfile
GKE_AMPQ_v1.png
LICENSE
README.md
build.gradle
deploy_travisci.sh
gradlew
gradlew.bat

README.md

Build Status Layers Version

Election Service

Introduction

The Election Spring Boot Service is a RESTful Web Service, backed by MongoDB, using Atlas on GCP, and RabbitMQ, using CloudAMQP on GCP. It is part of the Voter API (see diagram below). The Election service exposes several HTTP API endpoints, listed below. API users can manage elections and inspect technical information about the running service.

Architecture

Election Service Endpoints

The service uses a context path of /election. All endpoints must be are prefixed with this sub-path.

Purpose Method Endpoint
List All Service Endpoints GET /election/mappings
Create Election POST /election/elections
Read Election GET /election/elections/{id}
Read Elections GET /election/elections
Update Election PUT /election/elections/{id}
Delete Election DELETE /election/elections/{id}
Distinct List of Elections GET /election/summary
Drop All Elections POST /election/drop/elections
Service Info GET /election/election/info
Service Health GET /election/health
Other Spring Actuator endpoints GET election/actuator, election/metrics, election/env, election/configprops, etc.
Other HATEOAS endpoints for /election/elections Various page sort, size, etc.

The HAL Browser API browser for the hal+json media type is installed alongside the service. It can be accessed at http://localhost:8095/election/actuator/.

Elections

Creating a new election requires an HTTP POST request to the /election/elections endpoint, as follows:

Using HTTPie command line HTTP client.

http POST http://localhost:8095/election/elections \
  date='2008-11-04' \
  electionType='FEDERAL' \
  title='2008 Presidential Election' \
  description='56th quadrennial American presidential election'
http POST http://localhost:8095/election/elections \
  date='2008-11-04' \
  electionType='FEDERAL' \
  title='2008 Presidential Election' \
  description='56th quadrennial American presidential election'

wget

wget --method POST \
  --header 'content-type: application/json' \
  --body-data '{ "electionType": "2008-11-04", "electionType": "FEDERAL", "title": "2008 Presidential Election", "description": "56th quadrennial American presidential election" }' \
  --no-verbose \
  --output-document - http://localhost:8095/election/elections

Sample Output

HTTP/1.1 201
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type, Accept, X-Requested-With, remember-me
Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE
Access-Control-Max-Age: 3600
Content-Type: application/json;charset=UTF-8
Date: Mon, 15 May 2017 00:05:57 GMT
Location: http://localhost:8095/election/elections/5918f0e51162e16da6d1cb8c
Transfer-Encoding: chunked
X-Application-Context: Election Service:8095
{
    "_links": {
        "election": {
            "href": "http://localhost:8095/election/elections/5918f0e51162e16da6d1cb8c"
        },
        "self": {
            "href": "http://localhost:8095/election/elections/5918f0e51162e16da6d1cb8c"
        }
    },
    "date": "2008-11-04T00:00:00.000+0000",
    "electionType": "FEDERAL",
    "title": "2008 Presidential Election",
    "description": "56th quadrennial American presidential election"
}