I would try something like this (two routers):
Router usernameRouter = new Router(getContext());
router.attach("/users/{username}/", authorizer);
Router otherRouter = new Router(getContext()); // I'm sure you'll find a
better name
authorizer.setNext(otherRouter);
otherRouter.attach("", UserResource.class);
otherRouter.attach("docs/", DocsResource.class);
otherRouter.attach("docs/{id}/", DocResource.class);
authenticator.setNext(usernameRouter);
(Not sure if I got the starting "/" right.)
Best wishes,
Bruno.
On 29/06/10 12:53, Carles Barrobés wrote:
> Thanks Bruno, what you suggest is what I first tried - but gosh I didn't
> find the way to do the chaning. In a hierarchical setup such as:
>
> public Restlet createRoot() {
> ChallengeAuthenticator authenticator = createAuthenticator();
>
> Router router = new Router(getContext());
> router.attach("/users/{username}/", UserResource.class);
> router.attach("/users/{username}/docs/", DocsResource.class);
> router.attach("/users/{username}/docs/{id}/", DocResource.class);
> // ...
>
> authenticator.setNext(router);
> return authenticator;
> }
>
> How do I sneak in my authorizer in between the router and the resource
> totally escapes me, and believe me I made a few trials.
>
> Thanks again,
> Carles
>
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2627339