Hi all,
There is indeed a way to configure the routing to "eat" the '/' inside your
variable:
Route myRoute = router.attach("/ABC/{param1}/{param2}", MyResource.class);
myRoute.getTemplate().getVariables().get("param1").setType(Variable.TYPE_UIR_PATH);
Do consider the other advices. You might also want to explore matrix parameters
if your param1 and param2 are not really
hierarchical:
Route myRoute = router.attach("/ABC/{param1};{param2}", MyResource.class);
Hope it helps,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
-----Message d'origine-----
De : Fernando Padilla [mailto:[email protected]]
Envoye : mercredi 28 janvier 2009 19:22
A : [email protected]
Objet : Re: Request parameters with / in the value
heads up. Do not use url encoding for values within the path. :)
Because some browsers/appservers decode them aggressively.. (so it will
look like a "/" not "%2F" haphazardly.. So if you must encode within a
path, use a different encoding format..
Rob Heittman wrote:
> Free-associating here ... I expect that someone will write with a really
> cool way to construct the server-side patterns to meet your
> requirements! But aesthetically, I'd probably like the API better if it
> escaped slashes if they occur internally in a single token.
>
> http://localhost/myApp/ABC/1900%2Ftree/leaf
>
> This "reads" straightforwardly to me outside of any Restlet specific
> implementation -- I know that you mean 1900%2Ftree to go together as one
> hierarchical token, and %__ immediately tells me that there's some
> uri-unescaping to do.
>
> This approach may not work for you -- it can lead down a slippery slope
> of whether and when to un-escape. But it does read quite transparently
> for a REST (not necessarily Restlet) API specification.
>
> - R
>
> On Wed, Jan 28, 2009 at 3:32 AM, <[email protected]
> <mailto:[email protected]>> wrote:
>
> Hi,
>
> How to pass a value(parameter) to the resource in a URI with / as
> a part of the data. That means i have a resource registered like
>
> router.attach("/ABC/{param1}/{param2}",MyResource.java);
>
> the invocation URI given in browser is
> "http://localhost/myApp/ABC/1900/tree/leaf"
>
> as per my requirement param1 should get "1900/tree" and param2
> should get "leaf". restlet is taking / as a separator which i want
> to avoid.
>
> help me to solve this ...
>
> ------------------------------------------------------
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1062236
>
> <http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1062236>
>
>
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1063911
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1073906