NAME

MojoX::Controller - Controller Base Class

SYNOPSIS

use base 'MojoX::Controller';

DESCRIPTION

MojoX::Controller is an abstract controllers base class.

ATTRIBUTES

MojoX::Controller implements the following attributes.

app

my $app = $c->app;
$c      = $c->app(MojoSubclass->new);

A reference back to the application that dispatched to this controller.

tx

my $tx = $c->tx;

The transaction that is currently being processed.

METHODS

MojoX::Controller inherits all methods from Mojo::Base and implements the following new ones.

$c         = $c->cookie(foo => 'bar');
$c         = $c->cookie(foo => 'bar', {path => '/'});
my $value  = $c->cookie('foo');
my @values = $c->cookie('foo');

Access request cookie values and create new response cookies.

req

my $req = $c->req;

Alias for $c-tx->req>. Usually refers to a Mojo::Message::Request object.

res

my $res = $c->res;

Alias for $c-tx->res>. Usually refers to a Mojo::Message::Response object.

$c         = $c->signed_cookie(foo => 'bar');
$c         = $c->signed_cookie(foo => 'bar', {path => '/'});
my $value  = $c->signed_cookie('foo');
my @values = $c->signed_cookie('foo');

Access signed request cookie values and create new signed response cookies.

stash

my $stash = $c->stash;
my $foo   = $c->stash('foo');
$c        = $c->stash({foo => 'bar'});
$c        = $c->stash(foo => 'bar');

Non persistent data storage and exchange.

$c->stash->{foo} = 'bar';
my $foo = $c->stash->{foo};
delete $c->stash->{foo};

SEE ALSO

Mojolicious, Mojolicious::Guides, http://mojolicious.org.