use Catalyst qw[-Engine=Test];
-__PACKAGE__->action(
- foo => sub {
- my ( $self, $c ) = @_;
- $c->res->redirect('http://localhost/bar');
- }
-);
+sub foo : Global {
+ my ( $self, $c ) = @_;
+ $c->res->redirect('http://localhost/bar');
+}
+
+__PACKAGE__->setup;
package main;
use Catalyst qw[-Engine=Test];
-__PACKAGE__->action(
- foo => sub {
- my ( $self, $c ) = @_;
- $c->stash->{test} ||= 'foo';
- $c->forward('bar');
- },
- bar => sub {
+sub foo : Global {
+ my ( $self, $c ) = @_;
+ $c->stash->{test} ||= 'foo';
+ $c->forward('bar');
+}
+sub bar : Global {
my ( $self, $c ) = @_;
$c->stash->{test} ||= 'bar';
$c->forward('yada');
- },
- yada => sub {
+}
+sub yada : Global {
my ( $self, $c ) = @_;
$c->stash->{test} ||= 'yada';
$c->res->output( $c->stash->{test} );
- }
-);
+}
+
+__PACKAGE__->setup;
package main;
use Catalyst qw[-Engine=Test];
-__PACKAGE__->action(
- '!default' => sub {
- my ( $self, $c ) = @_;
- $c->res->output('bar');
- }
-);
+sub default : Private {
+ my ( $self, $c ) = @_;
+ $c->res->output('bar');
+}
+
+__PACKAGE__->setup;
package TestApp::C::Foo::Bar;
-TestApp->action(
- '!default' => sub {
- my ( $self, $c ) = @_;
- $c->res->output('yada');
- }
-);
+use base 'Catalyst::Base';
+
+sub default : Private {
+ my ( $self, $c ) = @_;
+ $c->res->output('yada');
+}
package main;
use Catalyst qw[-Engine=Test];
-__PACKAGE__->action(
- '!begin' => sub {
- my ( $self, $c ) = @_;
- $c->res->output('foo');
- },
+sub begin : Private {
+ my ( $self, $c ) = @_;
+ $c->res->output('foo');
+}
- '!default' => sub { },
+sub default : Private { }
- '!end' => sub {
- my ( $self, $c ) = @_;
- $c->res->output( $c->res->output . 'bar' );
- },
+sub end : Private {
+ my ( $self, $c ) = @_;
+ $c->res->output( $c->res->output . 'bar' );
+}
-);
-package TestApp::C::Foo::Bar;
+__PACKAGE__->setup;
-TestApp->action(
+package TestApp::C::Foo::Bar;
- '!begin' => sub {
- my ( $self, $c ) = @_;
- $c->res->output('yada');
- },
+use base 'Catalyst::Base';
- '!default' => sub { },
+sub begin : Private {
+ my ( $self, $c ) = @_;
+ $c->res->output('yada');
+}
- '!end' => sub {
- my ( $self, $c ) = @_;
- $c->res->output('yada');
- $c->res->output( $c->res->output . 'yada' );
- },
+sub default : Private { }
-);
+sub end : Private {
+ my ( $self, $c ) = @_;
+ $c->res->output( $c->res->output . 'yada' );
+}
package main;
use Catalyst qw[-Engine=Test];
-__PACKAGE__->action(
- hostname => sub {
- my ( $self, $c ) = @_;
- $c->res->output( $c->req->hostname );
- },
- address => sub {
- my ( $self, $c ) = @_;
- $c->res->output( $c->req->address );
- }
-);
+sub hostname : Global {
+ my ( $self, $c ) = @_;
+ $c->res->output( $c->req->hostname );
+}
+sub address : Global {
+ my ( $self, $c ) = @_;
+ $c->res->output( $c->req->address );
+}
package main;