Archive for February 23rd, 2007

URI Templates in RESTEasy

Friday, February 23rd, 2007

One nice feature of RESTEasy is its support for URI Templates. The URI Template spec defines a means of embedding variables in the URI. So the following URI Template:

http://somehost/contacts/{contactId}

Could return an XML document for a contact where the contactId=234:

http://somehost/contacts/234

In this example, we might be executing the following Java method:

@HttpMethod(”GET”)
public Contact getContactById(@URLParam(”contactId”) Long contactId) {
[...]