forked from mojolicious/mojo
-
Notifications
You must be signed in to change notification settings - Fork 0
Request data
datamuc edited this page Dec 2, 2010
·
13 revisions
TODO: add examples for lite apps**
To get access to request data of the current transaction, you can call the req method on the controller object via
my $request_object = $self->req;The request object is an instance of Mojo::Message::Request which inherits from Mojo::Message. You might look there for more in depth documentation.
To get a specific value that has been submitted via POST, call
my $name = $self->req->body_params->param('name');As there might be more than one value for each parameter key, you can also get all parameter values for a specific key, not only the first one, as in the previous example. Just use the array context:
my @names = $self->req->body_params->param('name');Calling $self->req->body_params provides an instance of Mojo::Parameters. You might look there for more in depth documentation.