8d27d80184bb3dfd23251543c14432e46b25bbf5
[catagits/CatalystX-Declare.git] / examples / MyApp-Web / lib / MyApp / Web / Controller / Root.pm
1 use CatalystX::Declare;
2
3 namespace MyApp::Web;
4
5 # we consume a role that does what the RenderView action class
6 # would normally do
7 controller ::Controller::Root 
8       with ::ControllerRole::RenderView {
9
10     # $CLASS is provided by CLASS.pm
11     $CLASS->config(namespace => '');
12
13
14     # this is the common root action for all other actions
15     action base under '/' as '';
16
17     # we group all our root actions under the common base
18     under base {
19
20         # this action catches /
21         final action root as '' {
22
23             $ctx->response->body( $ctx->welcome_message );
24         }
25
26         # this action takes all other /* parts. the (@) signature
27         # says we don't care about the arguments
28         final action not_found (@) as '' {
29
30             $ctx->response->body( 'Page Not Found' );
31             $ctx->response->status( 404 );
32         }
33     }
34 }