Re: GET query parameters
Hello Stokes, Your approach seems ok for me. Your Gadget Resource is well identified, and you just want to customize the representation of a gadget. Just attach your resource with the simple pattern /gadgets/{gadgetId}. Then, in your resource, you can get the query parameters just as follow : Form form = request.getResourceRef().getQueryAsForm(); and ask for the value of parameter includeGizmoDetail just as follow : form.getFirstValue(includeGizmoDetail); Best regards, Thierry Boileau I'm using Restlets mainly for read-only access to domain objects, which are rendered as XML. In some cases I would like the amount of detail in the representation to be specified in the request. For example, if Gadgets contain Gizmos, then I have: http://myhost.com/rest/gadgets/1234 for the details of a Gadget http://myhost.com/rest/gadgets/1234/gizmos for the Gizmos within a Gadget http://myhost.com/rest/gadgets/1234/gizmos/5678 for the details of a Gizmo But in some cases, I need to fetch a Gadget with all its Gizmo data inline. I was thinking something like: http://myhost.com/rest/gadgets/1234?includeGizmoDetail=true First, is this the right way to approach this problem? Second, if so, how can I access 'optional' query parameters like this from my Restlet? I can make the query parameter part of the pattern given to my Router (and access the includeGizmoDetail as a Request attribute), but then it doesn't match when the parameter isn't present. I can attach my Restlet twice to the Router with two patterns, but that doesn't feel right either. Thanks, Stokes.
Re: GET query parameters
Thierry Boileau thboileau at gmail.com writes: Your approach seems ok for me. Your Gadget Resource is well identified, and you just want to customize the representation of a gadget. Just attach your resource with the simple pattern /gadgets/{gadgetId}. Then, in your resource, you can get the query parameters just as follow : Form form = request.getResourceRef().getQueryAsForm(); and ask for the value of parameter includeGizmoDetail just as follow : form.getFirstValue(includeGizmoDetail); Thanks Thierry, that worked fine. The word Form threw me off, but makes sense now. Stokes.
GET query parameters
I'm using Restlets mainly for read-only access to domain objects, which are rendered as XML. In some cases I would like the amount of detail in the representation to be specified in the request. For example, if Gadgets contain Gizmos, then I have: http://myhost.com/rest/gadgets/1234 for the details of a Gadget http://myhost.com/rest/gadgets/1234/gizmos for the Gizmos within a Gadget http://myhost.com/rest/gadgets/1234/gizmos/5678 for the details of a Gizmo But in some cases, I need to fetch a Gadget with all its Gizmo data inline. I was thinking something like: http://myhost.com/rest/gadgets/1234?includeGizmoDetail=true First, is this the right way to approach this problem? Second, if so, how can I access 'optional' query parameters like this from my Restlet? I can make the query parameter part of the pattern given to my Router (and access the includeGizmoDetail as a Request attribute), but then it doesn't match when the parameter isn't present. I can attach my Restlet twice to the Router with two patterns, but that doesn't feel right either. Thanks, Stokes.