Hi Arjohn,

Good suggestion regarding the constants naming. I've just renamed routing
mode constants of Router to follow the MODE_*_MATCH pattern such as
MODE_BEST_MATCH instead of BEST. Deprecated older values.

Regarding the enums, we did consider them in several places but they prevent
addition of new constants by the framework or by the developer, especially
without breaking existing code. They also produce extra artifacts in the
Javadocs cluttering them.

For your latest question, I would recommend adding two routes: "/abc" and
"/abc/{path}". Then, it is possible to configure the "path" variable to say
it should match all URI characters including slashes via the
Variable#TYPE_URI_ALL constant, setting the Template#defaultVariable#type
property or adding an entry to Template#variables maps.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


-----Message d'origine-----
De : Arjohn Kampman [mailto:[email protected]] 
Envoyé : mercredi 4 novembre 2009 15:13
À : [email protected]
Objet : Re: Default routing mode change

Jerome Louvel wrote:
> Hi Arjohn,
> 
> Thanks for the positive feedback on Restlet 2.0!
> 
> The change on the Router was introduced to have a more predictable default
> setting. Currently, only the beginning of an URI has to match in order to
> follow the route (typically a ServerResource subclass). For example:
> 
>       router.attach("/abc", AbcResource.class)
> 
> was matching both "/abc" and "/abc/123" or "/abcefg"... This is useful for
> attaching Directory instances or for nested routers, but this isn't the
most
> common case.

Hi Jerome,

I think I misunderstood the meaning of Router.FIRST. I thought it meant
that the first route was used each time, but that wouldn't be a very
useful strategy for a router :-). I now understand that it means that
the first /matching/ route is chosen. Perhaps it would be a good idea to
rename this (and related) constants to Router.FIRST_MATCH to clarify
this?

This might have been discussed before: but did you consider using enums
for these kind of constants? Enums make it a bit easier to find the
possible options in an IDE with auto-code-completion. I had some trouble
finding the constants for Router.setDefaultMatchingMode(...) yesterday.

Finally: is there an easy way to create a router that will only match
complete path segments? I.e.: make "/abc" match "/abc" and "/abc/123",
but not "/abcdefg". I assume that this is one of the most used routing
option, but making it work like this is a challenge.

Arjohn

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

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

Reply via email to