I have just started learning Catalyst myself, but I can say that seems to be what :Args
is for. You specify the number of parameters you need and they are added to @_
. I have made this test:
sub test :Local :Args(1) {
my ( $self, $c, $word ) = @_;
$c->response->body($word);
}
and loaded http://localhost:3000/test/hello
. This displayed "hello" in the browser and the server output:
[info] *** Request 1 (0.083/s) [14444] [Thu Jun 5 11:29:18 2014] ***
[debug] Path is "test"
[debug] Arguments are "hello"
[debug] "GET" request for "test/hello" from "127.0.0.1"
[debug] Response Code: 200; Content-Type: text/html; charset=utf-8; Content-Length: unknown
[info] Request took 0.00722s (138.504/s)
.------------------------------------------------------------+-----------.
| Action | Time |
+------------------------------------------------------------+-----------+
| /test | 0.000194s |
| /end | 0.000265s |
'------------------------------------------------------------+-----------'
This is documented in Catalyst::Manual::Intro
under Action types.
It is also possible for a series of controller methods to examine the same request, each taking a certain number of those "URL parameters", with :CaptureArgs
and action chains.