On Friday 2008.10.17, at 04:01 , Jerome Louvel wrote:
[...]
In combination with MODE_EQUALS, you could also add a variable for your extensions like: "/foos/{foo}/bar.{ext}". That could reduce the number of
alternative routes you would have to attach.

Yes and no.  I use that trick but I still have to also have e.g.:
/foos/{foo}/bar
as well since the dot shouldn't be there if there's no extension. When I last looked, I couldn't find any way to make things optional (so if it's still not possible to do that in the latest versions, I'd suggest looking into it -- something like /bar(.{ext})? so that it hangs together properly).

FWIW, I do send both to the same resource and just have the resource look for the optional parts. e.g.:
        ext = (String) request.getAttributes().get("ext");
        if (null == ext)
            ext = "";

I've also used a combination of EQUALS and the default STARTS_WITH to keep the numbers of routes a bit more manageable.

Take care,
John

Reply via email to