Add HTTP support
[catagits/Catalyst-View-Component-SubInclude.git] / t / lib / ESITest / Controller / Root.pm
1 package ESITest::Controller::Root;
2
3 use strict;
4 use warnings;
5 use base 'Catalyst::Controller';
6
7 __PACKAGE__->config->{namespace} = '';
8
9 sub auto : Private {
10     my ( $self, $c ) = @_;
11     $c->stash->{'current_view'} = 'TT';
12     return 1;
13 }
14
15 sub index :Path Args(0) {}
16
17 sub base : Chained('/') PathPart('') CaptureArgs(0) {}
18
19 sub time_include : Chained('base') PathPart('time') Args(0) {
20     my ( $self, $c ) = @_;
21     my $params = $c->req->params;
22
23     $c->stash->{current_time} = localtime();
24     
25     my $additional = '';
26     for my $key (keys %$params) {
27         $additional .= "| $key = $params->{$key} | "
28     }
29
30     $c->stash->{additional} = $additional;
31     
32 }
33
34 sub capture : Chained('base') PathPart('') CaptureArgs(1) {
35     my ( $self, $c, $arg ) = @_;
36     $c->log->debug("Capture: $arg") if $c->debug;
37     $c->stash->{additional} = "Capture Arg: $arg";
38 }
39
40 sub time_args : Chained('capture') PathPart('time') Args(0) {
41     my ( $self, $c ) = @_;
42     my $params = $c->req->params;
43
44     $c->stash->{current_time} = localtime();
45
46     my $additional = $c->stash->{additional};
47     for my $key (keys %$params) {
48         $additional .= "| $key = $params->{$key} | "
49     }
50
51     $c->stash->{additional} = $additional;
52
53     $c->stash->{template} = 'time_include.tt';
54 }
55
56 sub time_args_with_args : Chained('capture') PathPart('time') Args(1) {
57     my ( $self, $c, $arg ) = @_;
58     my $params = $c->req->params;
59
60     $c->stash->{current_time} = localtime();
61
62     my $additional = $c->stash->{additional};
63     for my $key (keys %$params) {
64         $additional .= " | $key = $params->{$key} | "
65     }
66
67     $additional .= " Action Arg: $arg ";
68
69     $c->stash->{additional} = $additional;
70
71     $c->stash->{template} = 'time_include.tt';
72 }
73
74 sub time_args_without_capture : Chained('base') PathPart('time') Args(1) {
75     my ( $self, $c, $arg ) = @_;
76     my $params = $c->req->params;
77
78     $c->stash->{current_time} = localtime();
79
80     my $additional = '';
81     for my $key (keys %$params) {
82         $additional .= " | $key = $params->{$key} | "
83     }
84
85     $additional .= " Action Arg: $arg ";
86
87     $c->stash->{additional} = $additional;
88
89     $c->stash->{template} = 'time_include.tt';
90 }
91
92 sub time_args_no_chained : Path('time_args_no_chained') Args {
93     my ($self, $c, @args) = @_;
94
95     my $params = $c->req->params;
96
97     $c->stash->{current_time} = localtime();
98
99     my $additional = '';
100     for my $key (keys %$params) {
101         $additional .= " | $key = $params->{$key} | "
102     }
103
104     $additional .= " No Chained Args: " . join ', ', @args;
105
106     $c->stash->{additional} = $additional;
107
108     $c->stash->{template} = 'time_include.tt';
109 }
110
111 sub http : Chained('base') PathPart('') CaptureArgs(0) {
112     pop->stash->{'current_view'} = 'TTWithHTTP';
113 }
114
115 sub http_cpan : Chained('http') Args(0) {}
116
117 sub http_github : Chained('http') Args(0) {}
118
119 sub end : ActionClass('RenderView') {}
120
121 1;