[Catalyst] Literal controller

Chisel Wright chisel at herlpacker.co.uk
Thu Dec 1 00:56:37 CET 2005


Well you're doing something different. I just did:

catalyst.pl RootTest
cd RootTest/
vi lib/RootTest.pm

I added the following under the default{} sub:

  sub index : Private {
    my ($self, $c) = @_;
    $c->response->output('I catch the root slash');
  }

After that:

---- cut here ----
chisel at thea /tmp/RootTest $ ./script/roottest_test.pl /
[Wed Nov 30 23:51:30 2005] [catalyst] [debug] Debug messages enabled
[Wed Nov 30 23:51:31 2005] [catalyst] [debug] Loaded plugins:
.--------------------------------------------------------------------.
| Catalyst::Plugin::Static::Simple                                   |
'--------------------------------------------------------------------'

[Wed Nov 30 23:51:31 2005] [catalyst] [debug] Loaded dispatcher "Catalyst::Dispatcher"
[Wed Nov 30 23:51:31 2005] [catalyst] [debug] Loaded engine "Catalyst::Engine::CGI"
[Wed Nov 30 23:51:31 2005] [catalyst] [debug] Found home "/tmp/RootTest"
[Wed Nov 30 23:51:31 2005] [catalyst] [debug] Loaded Private actions:
.----------------------+------------------------------+--------------.
| Private              | Class                        | Method       |
+----------------------+------------------------------+--------------+
| /index               | RootTest                     | index        |
| /default             | RootTest                     | default      |
'----------------------+------------------------------+--------------'

[Wed Nov 30 23:51:31 2005] [catalyst] [info] RootTest powered by Catalyst 5.56
[Wed Nov 30 23:51:31 2005] [catalyst] [debug] **********************************
[Wed Nov 30 23:51:31 2005] [catalyst] [debug] * Request 1 (1.000/s) [6353]
[Wed Nov 30 23:51:31 2005] [catalyst] [debug] **********************************
[Wed Nov 30 23:51:31 2005] [catalyst] [debug] "GET" request for "" from "127.0.0.1"
[Wed Nov 30 23:51:31 2005] [catalyst] [info] Request took 0.029176s (34.275/s)
.--------------------------------------------------------+-----------.
| Action                                                 | Time      |
+--------------------------------------------------------+-----------+
| /index                                                 | 0.000101s |
'--------------------------------------------------------+-----------'

I catch the root slash
---- cut here ----

And to test it with a controller:

./script/roottest_create.pl controller Foo
vi lib/RootTest/Controller/Foo.pm

and added (making sure it wasn't part of the POD)

  sub index : Private {
    my ( $self, $c ) = @_;
    $c->response->output('I am the lord of Foo!');
  }

Then:
---- cut here ----
chisel at thea /tmp/RootTest $ ./script/roottest_test.pl /foo
[Wed Nov 30 23:56:13 2005] [catalyst] [debug] Debug messages enabled
[Wed Nov 30 23:56:13 2005] [catalyst] [debug] Loaded plugins:
.------------------------------------------------------------------------------.
| Catalyst::Plugin::Static::Simple                                             |
'------------------------------------------------------------------------------'

[Wed Nov 30 23:56:13 2005] [catalyst] [debug] Loaded dispatcher "Catalyst::Dispatcher"
[Wed Nov 30 23:56:13 2005] [catalyst] [debug] Loaded engine "Catalyst::Engine::CGI"
[Wed Nov 30 23:56:13 2005] [catalyst] [debug] Found home "/tmp/RootTest"
[Wed Nov 30 23:56:13 2005] [catalyst] [debug] Loaded components:
.-------------------------------------------------------------------+----------.
| Class                                                             | Type     |
+-------------------------------------------------------------------+----------+
| RootTest::Controller::Foo                                         | instance |
'-------------------------------------------------------------------+----------'

[Wed Nov 30 23:56:13 2005] [catalyst] [debug] Loaded Private actions:
.----------------------+----------------------------------------+--------------.
| Private              | Class                                  | Method       |
+----------------------+----------------------------------------+--------------+
| /index               | RootTest                               | index        |
| /default             | RootTest                               | default      |
| /foo/index           | RootTest::Controller::Foo              | index        |
'----------------------+----------------------------------------+--------------'

[Wed Nov 30 23:56:13 2005] [catalyst] [info] RootTest powered by Catalyst 5.56
[Wed Nov 30 23:56:13 2005] [catalyst] [debug] **********************************
[Wed Nov 30 23:56:13 2005] [catalyst] [debug] * Request 1 (1.000/s) [6383]
[Wed Nov 30 23:56:13 2005] [catalyst] [debug] **********************************
[Wed Nov 30 23:56:13 2005] [catalyst] [debug] "GET" request for "foo" from "127.0.0.1"
[Wed Nov 30 23:56:13 2005] [catalyst] [debug] Path is "foo"
[Wed Nov 30 23:56:13 2005] [catalyst] [info] Request took 0.029929s (33.412/s)
.------------------------------------------------------------------+-----------.
| Action                                                           | Time      |
+------------------------------------------------------------------+-----------+
| /foo/index                                                       | 0.000067s |
'------------------------------------------------------------------+-----------'

I am the lord of Foo!
---- cut here ----

Looks OK to me ...
-- 
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