Commit | Line | Data |
2140e65c |
1 | package ExternalCatty::Controller::Root; |
2 | use strict; |
3 | use warnings; |
4 | |
5 | use base qw/ Catalyst::Controller /; |
6 | |
7 | __PACKAGE__->config( namespace => '' ); |
8 | |
9 | sub default : Private { |
10 | my ( $self, $c ) = @_; |
11 | $c->response->content_type('text/html; charset=utf-8'); |
12 | $c->response->output( html( 'Root', 'Hello, test ☺!' ) ); |
13 | } |
14 | |
15 | # redirect to a redirect |
16 | sub hello: Global { |
17 | my ( $self, $context ) = @_; |
18 | my $where = $context->uri_for('/'); |
19 | $context->response->redirect($where); |
20 | return; |
21 | } |
22 | |
23 | sub html { |
24 | my ( $title, $body ) = @_; |
25 | return qq[ |
26 | <html> |
27 | <head> |
28 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
29 | <title>$title</title> |
30 | </head> |
31 | <body>$body</body> |
32 | </html> |
33 | ]; |
34 | } |
35 | |
4ab99758 |
36 | sub host : Global { |
37 | my ($self, $c) = @_; |
38 | |
39 | my $host = $c->req->header('Host') || "<undef>"; |
40 | my $html = html( $c->config->{name}, "Host: $host" ); |
41 | $c->response->content_type("text/html"); |
42 | $c->response->output($html); |
43 | } |
44 | |
2140e65c |
45 | 1; |
46 | |