sub build {
my $self = shift;
my $r = $self->routes;
$r->add( '/', 'page' );
$r->add( '/strange', 'strange_manipulations' );
}
sub page {
my ($self) = @_;
my $message = $self->param('message');
my %hash;
if( $message ) {
$hash{'message'} = $message;
}
$self->res->template( 'page.tt', \%hash );
}
sub strange_manipulations {
my $self = shift;
my $message = "wow! wow! easy there!";
$self->res->redirect_to( '/?message=' . $message );
}
Redirects the client to a named route or to a given url. In case the route is passed by name, a hash reference with the needed arguments can be passed after the route's name. As a third optional argument, you can enter the desired response code:
$self
->redirect_to(
'catalogue'
, {
id
=> 243 });