[Catalyst] Handling a path of '/'
Chisel Wright
chisel at herlpacker.co.uk
Fri Dec 2 00:40:58 CET 2005
On Thu, Dec 01, 2005 at 05:04:03PM -0600, Justin Guenther wrote:
> Am I missing something? Any help would be appreciated.
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.
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.
More information about the Catalyst
mailing list