Catalyst-Runtime
view release on metacpan or search on metacpan
lib/Catalyst.pm view on Meta::CPAN
You can use:
$c->uri_for_action('/users/lst')
and it will create the URI /users/the-list.
=item \@captures_and_args?
Optional array reference of Captures (i.e. C<CaptureArgs> or C<< $c->req->captures >>)
and arguments to the request. Usually used with L<Catalyst::DispatchType::Chained>
to interpolate all the parameters in the URI.
=item @args?
Optional list of extra arguments - can be supplied in the
C<< \@captures_and_args? >> array ref, or here - whichever is easier for your
code.
Your action can have zero, a fixed or a variable number of args (e.g.
C<< Args(1) >> for a fixed number or C<< Args() >> for a variable number)..
=item \%query_values?
Optional array reference of query parameters to append. E.g.
{ foo => 'bar' }
will generate
/rest/of/your/uri?foo=bar
=back
=cut
sub uri_for_action {
my ( $c, $path, @args ) = @_;
my $action = blessed($path)
? $path
: $c->dispatcher->get_action_by_path($path);
unless (defined $action) {
croak "Can't find action for path '$path'";
}
return $c->uri_for( $action, @args );
}
=head2 $c->welcome_message
Returns the Catalyst welcome HTML page.
=cut
sub welcome_message {
my $c = shift;
my $name = $c->config->{name};
my $logo = $c->uri_for('/static/images/catalyst_logo.png');
my $prefix = Catalyst::Utils::appprefix( ref $c );
$c->response->content_type('text/html; charset=utf-8');
return <<"EOF";
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Language" content="en" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>$name on Catalyst $VERSION</title>
<style type="text/css">
body {
color: #000;
background-color: #eee;
}
div#content {
width: 640px;
margin-left: auto;
margin-right: auto;
margin-top: 10px;
margin-bottom: 10px;
text-align: left;
background-color: #ccc;
border: 1px solid #aaa;
}
p, h1, h2 {
margin-left: 20px;
margin-right: 20px;
font-family: verdana, tahoma, sans-serif;
}
a {
font-family: verdana, tahoma, sans-serif;
}
:link, :visited {
text-decoration: none;
color: #b00;
border-bottom: 1px dotted #bbb;
}
:link:hover, :visited:hover {
color: #555;
}
div#topbar {
margin: 0px;
}
pre {
margin: 10px;
padding: 8px;
}
div#answers {
padding: 8px;
margin: 10px;
background-color: #fff;
border: 1px solid #aaa;
}
h1 {
font-size: 0.9em;
font-weight: normal;
text-align: center;
}
h2 {
font-size: 1.0em;
}
p {
font-size: 0.9em;
( run in 1.336 second using v1.01-cache-2.11-cpan-677af5a14d3 )