Hi Tal,
Thanks for the feed-back. Yes, I did update the Javadocs of Directory to explain this with a code sample!
Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~
http://www.restlet.orgNoelios Technologies ~ Co-founder ~
http://www.noelios.com-----Message d'origine-----
De : Tal Liron [mailto:
[hidden email]]
Envoyé : mardi 13 octobre 2009 15:51
À :
[hidden email]
Objet : Re: Changing default Router configuration
This makes sense to me. In particular, it will avoid some of the
"trailing slash" problems that have plagued newcomers.
I think, though, that's important to add a note regarding Directory use
to its main Java API documentation. "If you attach Directory to a
router, you would probably want to ..."
-Tal
On 10/13/2009 07:54 AM, Jerome Louvel wrote:
>
> Hi all,
>
> Currently, the Router class is configured with the following properties:
>
> - defaultMatchingMode : MODE_START_WITH
>
> - defaultMatchQuery : true
>
> - routingMode : BEST
>
> While this configuration works fine in most cases, it has one
> significant drawback as unexpected URIs will match. For example, the
> “/path/123” attachment pattern would match “/path/123” but also
> “/path/123456” as the router only expects the beginning of the URI to
> match…
>
> This behavior can be changed manually but I think that Restlet 2.0
> gives us the opportunity to change this default behavior. So, I went
> ahead and changed the router default configuration in SVN trunk to:
>
> - defaultMatchingMode : MODE_EQUALS
>
> - defaultMatchQuery : false
>
> - routingMode : FIRST
>
> The impact on our test cases was minimal except for one thing:
> Directory. When attached to a Router a Directory is expected to manage
> the complete URI subspace. Therefore you need to manually change the
> matching mode in this case:
>
> Directory directory = new Directory(getContext(),
> “file:///user/data/files/”);
>
> Router router = new Router(getContext());
>
> TemplateRoute route = router.attach(“/static/”, directory);
>
> route.setMatchingMode(Template.MODE_STARTS_WITH);
>
> Note that VirtualHost, which is a Router subclass, has kept the
> previous configuration at it is almost never the last routing point.
>
> Let me know what you think, it is always time to revert or change to
> another behavior if I missed something important.
>
> Best regards,
> Jerome Louvel
> --
> Restlet ~ Founder and Lead developer ~
http://www.restlet.org
> <
http://www.restlet.org/>
> Noelios Technologies ~ Co-founder ~
http://www.noelios.com
> <
http://www.noelios.com/>
>
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=7458&dsMessageId=2407098------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=7458&dsMessageId=2407111