->req->remote_user support, new release
[catagits/Catalyst-Controller-WrapCGI.git] / t / lib / TestApp / Controller / Root.pm
1 package TestApp::Controller::Root;
2
3 use parent 'Catalyst::Controller::WrapCGI';
4 use CGI ();
5
6 __PACKAGE__->config->{namespace} = '';
7
8 my $cgi = sub {
9     my $cgi = CGI->new;
10     print $cgi->header;
11     print 'foo:',$cgi->param('foo'),' bar:',$cgi->param('bar');
12     if (my $fh = $cgi->param('baz')) {
13       local $/;
14       print ' baz:',<$fh>;
15     }
16     if (my $fh = $cgi->param('quux')) {
17       local $/;
18       print ' quux:',<$fh>;
19     }
20     die $cgi->cgi_error if $cgi->cgi_error;
21 };
22
23 sub handle_cgi : Path('/cgi-bin/test.cgi') {
24     my ($self, $c) = @_;
25     $self->cgi_to_response($c, $cgi);
26 }
27
28 sub test_path_info : Path('/cgi-bin/test_pathinfo.cgi') {
29     my ($self, $c) = @_;
30
31     $self->cgi_to_response($c, sub {
32         my $cgi = CGI->new;
33         print $cgi->header;
34         print $ENV{PATH_INFO}
35     });
36 }
37
38 sub test_filepath_info : Path('/cgi-bin/test_filepathinfo.cgi') {
39     my ($self, $c) = @_;
40
41     $self->cgi_to_response($c, sub {
42         my $cgi = CGI->new;
43         print $cgi->header;
44         print $ENV{FILEPATH_INFO}
45     });
46 }
47
48 sub test_script_name_root : Chained('/') PathPart('cgi-bin') CaptureArgs(1) {}
49
50 sub test_script_name : Chained('test_script_name_root') PathPart('test_scriptname.cgi') Args {
51     my ($self, $c) = @_;
52
53     $self->cgi_to_response($c, sub {
54         my $cgi = CGI->new;
55         print $cgi->header;
56         print $ENV{SCRIPT_NAME}
57     });
58 }
59
60 sub test_remote_user : Path('/cgi-bin/test_remote_user.cgi') Args(0) {
61     my ($self, $c) = @_;
62
63     $self->cgi_to_response($c, sub {
64         my $cgi = CGI->new;
65         print $cgi->header;
66         print $ENV{REMOTE_USER}
67     });
68 }
69
70 1;