Hello Alex,

The routing mechanism is based on Template objects (http://www.restlet.org/docs/api/index.html?org/restlet/util/Template.html) and Variable objects. When defining a "route" with the "attach" method, a Template object is created and then associated with this "route". This Template object is in charge of parsing the requested URI and give it a score according to some attributes. then the Router can compare the score of each route defined and choose the one it prefers (*). The way the Template object assigns a score can be customized with the following modes :

   * MODE_START_WITH (default)
   * MODE_EQUALS

In order to solve your problem, you can use the "equals" mode :

***************

Route route = router.attach("/users/{user}", account);

route.getTemplate().setMatchingMode(Template.MODE_EQUALS);

***************

Otherwise, for a finer control, you can define the way variables (e.g. : {user}) are consumed in the URI. See (http://www.restlet.org/docs/api/index.html?org/restlet/util/Variable.html) for more details. The default variable defined on all Template objects matches a URI segment.


I hope this helps you.
Best regards,
Thierry Boileau


PS :
* 6 modes are available :

   * Best match (default)
   * First match
   * Last match
   * Random match
   * Round robin
   * Custom



Ok, I know that regex support has been removed, but I've run into a situation
where I kind of needed it.  The basic idea was that I wanted to match only
strings that conformed to a very rigid format.  So, taking from the tutorial, if
I did only
router.attach("/users/{user}", account);

and somebody tried to do "/users/blah/orders", I want it to not match anything.
 As it stands right now, it would match and call 'account' with 'blah' as the
user. I used to be able to do this by doing router.attach("/users/{user}$", account);
but that's removed now.  So how can I go about regaining this functionality?

-Alex

Reply via email to