Giter Club home page Giter Club logo

code-kata-challenge's Introduction

Code Kata challenge

Simple REST-ful service for vote counting and results generating system.

Technologies used

  • Java 8
  • Maven
  • Jersey
  • Jetty

Requirement

  • JDK 1.8
  • Maven 3.2

Example

@Path("poll-service")
public class PollService {

	...

	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public Response getPoll() {
		...
	}

	@POST
	@Path("/{pollName}")
	@Produces(MediaType.APPLICATION_JSON)
    	@Consumes(MediaType.APPLICATION_JSON)
	public Response countMeUp(
		@PathParam("pollName") String pollName, Vote vote) {
		...
	}

Build & Rest Server

mvn package
mvn exec:java

Rest Server start at After that you can use curl or your browser to test the different services.

Example

Request

curl -i http://localhost:2222/poll-service/ -H'Accept:application/json'

Response

HTTP/1.1 200 OK
Date: Thu, 11 May 2017 21:05:00 GMT
Content-Type: application/json
Content-Length: 53
Server: Jetty(9.2.14.v20151106)

{"totalVotes":15,"voteMap":{"A":5,"B":1,"C":2,"D":7}}

Request

curl -i -H "Content-Type: application/json" -X POST -d '{ "voter" : "AG", "candidate" : "D"}' http://localhost:2222/poll-service/poll1  -H'Accept:application/json'

Response

HTTP/1.1 201 Created
Date: Thu, 11 May 2017 21:04:05 GMT
Content-Type: application/json
Content-Length: 12
Server: Jetty(9.2.14.v20151106)

vote aquired

License

MIT

code-kata-challenge's People

Contributors

mario83 avatar

Watchers

 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.