- 11 Aug 2012: A complete re-write based on the Eligosource event-sourcing library is now available in the eventsourced-example repository which now represents the recommended approach how to implement event-sourced web applications.
- 23 Feb 2012: Work on branch play replaces the Jersey and Scalate-based web layer with Play Framework 2.0
sbt run-main dev.example.eventsourcing.server.Webserver
Then go to http://localhost:8080 and create some invoices.
The example application's RESTful service interface supports HTML, XML and JSON as representation formats. Content negotiation is done via the Accept
HTTP header. The following examples show how to get different representations of invoice-3
Enter http://localhost:8080/invoice/invoice-3 into your browser. Provided you have created an invoice with id invoice-3
before you should see something like
curl -H "Accept: application/xml" http://localhost:8080/invoice/invoice-3
yields
<draft-invoice id="invoice-3" version="2">
<total>12.8</total>
<sum>12.8</sum>
<discount>0</discount>
<items>
<item>
<description>item-1</description>
<count>1</count>
<amount>4.1</amount>
</item>
<item>
<description>item-2</description>
<count>3</count>
<amount>2.9</amount>
</item>
</items>
</draft-invoice>
curl -H "Accept: application/json" http://localhost:8080/invoice/invoice-3
yields
{
"draft-invoice":
{
"@id":"invoice-3",
"@version":"2",
"total":"12.8",
"sum":"12.8",
"discount":"0",
"items":
{
"item":
[
{
"description":"item-1",
"count":"1",
"amount":"4.1"
},
{
"description":"item-2",
"count":"3",
"amount":"2.9"
}
]
}
}
}