This post is linked to this question on StackOverflow - 
http://stackoverflow.com/questions/8223886/is-it-possible-to-have-strongly-typed-http-request-handlers-in-restlet

Specifically, I am interested to know how folks deal with the following 
scenario:

There is a User resource, which is avaible for GET from 
http://localhost/user/{id} and for POST to http://localhost/user. Apparently, I 
cannot utilize the same ServerResource instance for both GET and POST, because 
the @Get method would be invoked both for GET http://localhost/user/{id} and 
for GET http://localhost/user, meaning that @Get method will have to validate 
whether "{id}" is present and return 405 if not. To avoid this kind of 
validations, one will have to use two different ServerResource types - one for 
GET (and PUT and DELETE) and the other for POST, something like this:

    router.attach("/user/{id}", UserResourceGetPutDelete.class);
    router.attach("/user", UserResourcePost.class);

Still, my GET handler code is responsible for making sure the given id is an 
integer. Is it really how folks do it or am I missing anything?

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2889137

Reply via email to