«Top»

The following is an overview of the REST interface provided by our
example application.
The application’s client-side is static HTML and JavaScript,
using the REST interface to interact with the server.

The examples below show how the
REST
interface is called using the curl command line tool.

GET

The following requests the events for user “fabian”:

curl localhost:8080/rest/events/fabian

[
    "2013-04-19 14:11:49 \"Buy an item in US store\"",
    "2013-04-19 14:11:53 \"Buy an item in UK store\"",
    "2013-04-19 14:11:57 \"Buy an item in DE store\"",
    "2013-04-19 14:12:11 \"Payment refused\"",
    "2013-04-19 14:12:12 \"Payment refused\"",
    "2013-04-19 14:12:12 \"Payment refused\"",
    "2013-04-19 14:12:43 \"Account disabled\"",
    "2013-04-19 14:12:57 \"Log-in refused\"",
    "2013-04-19 14:12:58 \"Log-in refused\"",
    "2013-04-19 14:13:10 \"Create new account\""
]

POST

The following posts a new event for user “fabian”:

curl -H "Content-Type: application/json" \
    -X POST localhost:8080/rest/events/fabian \
    -d "Some new event"

How To Run

Our example code is hosted on GitHub.
In order to test the REST interface, our
Map-based reference implementation
can be run as follows:

mvn tomcat7:run-war -pl part01 -am verify

The Web interface is then accessible via
http://localhost:8080.

Next

As exemplified above, the REST interface is very simple. The following pages introduces the back-end part of our example application: