[Catalyst] Handling a path of '/'

Justin Guenther jguenther at gmail.com
Fri Dec 2 00:52:01 CET 2005

On 12/1/05, Chisel Wright <chisel at herlpacker.co.uk> wrote:

> This sounds very much like the example I posted yesterday - about much
> the same problem.
> It's my understanding (and yesterday's example seems to back me up) that
> you can use "sub index : Private { ... }" to catch '/' URLs.
> In MyApp.pm it would catch http://server:3000/ and in MyApp::C::Foo it
> would catch http://server:3000/foo/
> I think (but haven't tested) that one way would be for you to have the
> following in MyApp.pm:
> sub index : Private {
>   my ($self, $c) = @_;
>   $c->response->redirect('/menu');
> }
> Skimming the docs, "$c->forward('/menu')" may also work in place of the
> redirect.

Ah yes. I replaced `sub display_menu : Path('')' with `sub index : Private'
and it seems to work just fine. Is there a particular reason why my original
method didn't work in the root, but did for sub-controllers? It seems like a
bug to me...

I tend to take the lazy way out. My global default() redirects to 'the
> default application action' [e.g. /client/list] and each controller
> default usually redirects to the appropriate list view.
> That way, any rubbish URLs that people use will result in seeing
> something useful, instead of a 404.
> Chisel
> --
> Chisel Wright
> e: chisel at herlpacker.co.uk
> w: http://www.herlpacker.co.uk/
> No virus was found in this outgoing message as I didn't bother looking.
> _______________________________________________
> Catalyst mailing list
> Catalyst at lists.rawmode.org
> http://lists.rawmode.org/mailman/listinfo/catalyst
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20051201/8eb03520/attachment.htm

More information about the Catalyst mailing list