0409a7a132ba0e4d6f6da8c0b4265372365c1a99
[catagits/Test-WWW-Mechanize-Catalyst.git] / t / lib / ExternalCatty / Controller / Root.pm
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
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
45 1;
46