Hi Stephan,

Good idea, I've started a new "Advanced request routing" page on the wiki:
http://wiki.restlet.org/docs_1.1/g1/43-restlet/143-restlet.html 

Best regards,
Jerome


-----Message d'origine-----
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Envoyé : mercredi 16 juillet 2008 13:00
À : discuss@restlet.tigris.org
Objet : Re: Routing problem

Hi Thierry,

could you put this explanations somewhere on the net, e.g. the restlet 
wiki? Than other would find it there.

best regards
   Stephan

Thierry Boileau schrieb:
> Hi Ralf and John,
>
> we would like to explain  what leads us to provide the current solution.
>
> 1) to our minds, the routes "/foo" and "/foo/" identify two separate 
> resources. Mostly because this has an impact on relative URIs. When we 
> encountered this kind of issue when developping the o.r.Directory, we 
> decided to addressed it by doign a redirection (redirection to the URI 
> having the training "/").
>
> 2) Using sub-routers *requires* the usage of the STARTS_WITH mode. 
> Otherwise, the fooRouter will not accept to transmit URIs such as 
> /HOST/foo/bar/blah.
> This leads us to think that, in your case, you will be obliged to 
> combine STARTS_WITH and EQUALS modes.
>
> 3) It is possible to combine both modes on the same router: default 
> router mode + individual route mode.
> For example, regarding the fooRouter:
> - set the default matching mode to Template.MODE_EQUALS
> - attach the fooResource to the "" and/or "/" route according to your 
> need
> - attach the barRouter and update the matching mode of this route:
>     Route route = fooRouter.attach("/bar", barRouter);
>     route.setMatchingMode(Template.MODE_STARTS_WITH);
>     // This instruction has just been added to the Route class. It 
> replaces the following one.     // 
> route.getTemplate().setMatchingMode(Template.MODE_STARTS_WITH);
>
> We are not completely convinced to add a new matching mode but this 
> discussion is, of course, totally open.
>
> best regards,
> Thierry Boileau
>> Hello I have a little problem with routing which I just can't seem to 
>> find a workaround, perhaps someone here has some idea...
>>
>> Okay the thing is this:
>>
>> In my application I have some routers that are linked together like 
>> this:
>>
>> Router rootRouter = new Router(getContext());
>> Router fooRouter = new Router(getContext());
>> Router barRouter = new Router(getContext());
>>
>> rootRouter.attach("", rootResource.class);
>> rootRouter.attach("/foo", fooRouter);
>>
>> fooRouter.attach("", fooResource.class);
>> fooRouter.attach("/bar", barRouter);
>>
>> barRouter.attach("", barResource.class);
>> ... and so on...
>>
>> My problem is this: At the moment I use as matching route for the 
>> templates MODE_STARTS_WITH. The advantage is that its very forgiving, 
>> particular it doesn't care wether there is a slash a the end of the 
>> url or not. So HOST/foo leads to fooResource as well as HOST/foo/ .
>> The disadvantage is a that HOST/foo/nonsense matches (because of 
>> MODE_STARTS_WITH) fooResource as well, which is _not_ what is 
>> intended. (should get a 404 instead)
>>
>> Okay I can always use MODE_EQUALS right? Thats what I thought too, 
>> but I  quickly realised that that mode is a litte _too_ unforgiving 
>> for my needs: For example because of the very strict matching it will 
>> match HOST/foo but HOST/foo/ will lead to a 404. I tried with setting 
>> 2 strict routes, one with and one without the slash but then I got 
>> problems with the next router down the line.
>>
>> Summary: MODE_STARTS_WITH is a litte too forgiving, MODE_EQUALS a 
>> little to strict, particular in regard to slashes at the end (which 
>> should make no difference anyways)
>> Any ideas, tips, workarounds are highly welcome!
>>
>> Best regards
>> Ralf
>>
>>
>>
>>

Reply via email to