Hi Cliff,

you can also update the type of the declared variable in your URI template:

Route route = router.attach("/foos/{foo}/bar", sth);
Template template = route.getTemplate().setMatchingMode(Template.MODE_EQUALS);
template.getVariables().put("foo", new Variable(Variable.TYPE_WORD));

You can find the list of all variable types in the Variable class.

Otherwise, the routing process is based on URI template. If you want one based on regexp, I send you a sample template class based on regexp pattern and a server/client test code.


Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org <http://www.restlet.org/>
Noelios Technologies ~ Co-founder ~ http://www.noelios.com <http://www.noelios.com/>

Aron,

Thanks, I didn't realize this was here.  This would potentially work, and I
may end up using it.

Frankly, I want to be able to "have my cake and eat it too".  An exact match
using this construct would work, but would also force me to itemize every
possible variation of a path via router.attach().  I was hoping to do some
"fuzzy" enforcement in a base "Resource" class.

Cliff Binstock
Coyote Reporting




-----Original Message-----
From: Aron Roberts [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 16, 2008 11:37 AM
To: [email protected]
Subject: RE: uriPattern exactness

In the message "Re: uriPattern exactness", dated 2008-10-16, Cliff
Binstock wrote:

P.S.  What is worse (maybe very confusing) is that this might match too:
/foo/myFoo/bar/baz/bletch/fred.xml
Again, I would like to forcefully ensure that this doesn't end up
matching.

   From memory - by default, the mode for matching incoming URIs to
your URI templates is 'starts with' rather than 'equals'.

As Jerome wrote back in February 2008:
In some cases, you might want to change this default mode, and this
is easy to do via the "defaultMatchingMode" property on Router, or by
modifying the "matchingMode" property of the template associated with
the route created by the Router.attach() methods. For the modes, you can
use the Template.MODE_EQUALS or Template.MODE_STARTS_WITH constants."
   Here's one example of the latter:

router.getTemplate().setMatchingMode(Template.MODE_EQUALS)

   Hope this is germane to your needs.

Aron

Attachment: testTemplateCustomized.jar
Description: application/java-archive

Reply via email to