On Tue, Nov 29, 2011 at 3:54 PM, Mark Kharitonov
<[email protected]>wrote:

>    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?
>

This looks OK -- two resources, one corresponding to a single user (that
you can read, modify, and delete), the other corresponding to a collection
of users (to which you can only add new users). In order to avoid URI
matching problems, you might want to make the path for the second something
that isn't a prefix of the first, e.g., /users/. You don't have to name the
resource classes after the operations they support, since their annotations
make it clear in any case.

If you have common behavior (like validating a user id) that you want to
use in multiple resources you can put in an common superclass.

--tim

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

Reply via email to