I wound up using a Restlet instead of a Redirector or Filter, as I couldn't see how the infrastruture there helped me. It could be due to some miswiring on my side that I I need to use application.handle(), but that's what works for me.
public abstract class MyFilter extends Restlet { private final Application application; MyFilter(Application application) { this.application = application; } protected Reference getTargetRef(Request request, Response response); @Override public void handle(Request request, Response response) { Reference targetRef = getTargetRef(request, response); Reference resourceRef = request.getResourceRef(); request.setResourceRef(targetRef); application.handle(request, response); response.setEntity(response.getEntity()); request.setResourceRef(resourceRef); } } Leigh. On 02/11/2011 11:36 AM, Leigh L. Klotz, Jr. wrote: > > I just was about to send a similar message. > > I'd like to have a filter which does the following: > > 1. Versioned resources > /path/to/resources/{thing}/a/b/c --> /path/to/resource/a/b/c but with > {thing} available in a request attribute. > > 2. Resource aliases > /path/to/resources/foo/{thing}/a/b/c --> > /path/to/resource/foo/otherthing/a/b/c where the filter does the mapping > of "thing" to "otherthing" > > In neither case do I want the headers removed; I want them transparently > passed through/ > > Use cases: > > 1. {thing} is an API version, a schema version, or some other piece of > metadata which I can use to encourage clients to cache responses > forever, but which is optional. Using query strings for this purpose > fails because it requires you to avoid conflicts with every possible > resource. Using a URI path component works because you can provide > /path/to/resources/v123 as the root for clients of a particular vintage > or time scale. > > 2. {thing} is an alias for some other thing. For example "User" could > be an alias for current user id. > > In Restlet 2.0.1, so far failed.. > > For #1, I see no way to do it and need help. > > For #2, I interpose a starts_with template matcher for each resource > under "/path/to/resources", and it decide dynamically between calling > the real resource or doing a Redirector.MODE_CLIENT_TEMPORARY to the > rewritten resource, which of course goes back to the client. The client > redirect is especially unpleasant. > > > Leigh. > > ------------------------------------------------------ > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2703463 > > <http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2703463> > > > ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2704679