Skip to content
datamuc edited this page Dec 2, 2010 · 13 revisions

Request Data

TODO: add examples for lite apps**

Request Object

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.

Post Data

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.

Clone this wiki locally