Giter VIP home page Giter VIP logo

election-service's Introduction

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

election-service's People

Contributors

garystafford avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.