Hi Stokes,
Depending on the type of routing it maybe desirable to require an exact
match of the target URI (like in your case) or simply a match of the start
of the target URI (like in the case of a Directory finder).
The Router class uses the second mode (Template.START_WITH) by default when
you use the "attach(uriTemplate, next)" method. You can change this to the
stricter EQUALS mode by doing something like:
Route route = myRouter.attach("/foos/123", myFooFinder);
route.getTemplate().setMatchingMode(Template.MODE_EQUALS);
Best regards,
Jerome
> -----Message d'origine-----
> De : news [mailto:[EMAIL PROTECTED] De la part de Stokes
> Envoyé : mardi 20 mars 2007 16:01
> À : [email protected]
> Objet : Router and URLs with extra stuff at the end
>
> If I have a router with two Restlets attached as follows:
> /foos ==> FooListFinder
> /foos/{fooId} ==> FooFinder
>
> ... then, as expected, these request route as follows:
> /foos --routes to--> FooListFinder
> /foos?somearg=true --routes to--> FooListFinder
> /foos/123 --routes to--> FooFinder
> /foos/123?someotherarg=456 --routes to--> FooFinder
>
> All of that is good.
>
> But as a side-effect, I get these that I _don't_ want:
> /foos/123/garbage --routes to--> FooFinder
> /foos/123/more/garbage --routes to--> FooFinder
>
> Any suggestions for how to prevent these last two? I need to
> handle this at the
> framework/router level, so that the Finder implementations
> aren't concerned.
>
> In my case my API is very particular about syntax, so I want
> the last two
> requests above to result in an error page (400).
>
> Thanks,
> Stokes.