Commit | Line | Data |
2140e65c |
1 | package CattySession::Controller::Root; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use base qw/ Catalyst::Controller /; |
7 | |
8 | __PACKAGE__->config( namespace => '' ); |
9 | |
10 | sub auto : Private { |
11 | my ( $self, $context ) = @_; |
12 | if ( $context->session ) { |
13 | return 1; |
14 | } |
15 | |
16 | } |
17 | |
18 | sub default : Private { |
19 | my ( $self, $context ) = @_; |
20 | my $html = html( "Root", "This is the root page" ); |
21 | $context->response->content_type("text/html"); |
22 | $context->response->output($html); |
23 | } |
24 | |
25 | sub name : Global { |
26 | my ($self, $c) = @_; |
27 | |
28 | my $html = html( $c->config->{name}, "This is the die page" ); |
29 | $c->response->content_type("text/html"); |
30 | $c->response->output($html); |
31 | } |
32 | |
33 | |
34 | sub html { |
35 | my ( $title, $body ) = @_; |
36 | return qq{ |
37 | <html> |
38 | <head><title>$title</title></head> |
39 | <body> |
40 | $body |
41 | <a href="/hello/">Hello</a>. |
42 | </body></html> |
43 | }; |
44 | } |
45 | |
46 | 1; |
47 | |