13 return $self->handler();
17 shift->{cgi} = CGI::Simple->new();
23 my $cgi = $self->{cgi};
25 # Reconstruct the request headers (as far as this is possible)
26 $self->headers_in(Maypole::Headers->new);
27 for my $http_header ($cgi->http) {
28 (my $field_name = $http_header) =~ s/^HTTPS?_//;
29 $self->headers_in->set($field_name => $cgi->http($http_header));
32 $self->{path} = $cgi->url( -absolute => 1, -path_info => 1 );
33 my $loc = $cgi->url( -absolute => 1 );
34 no warnings 'uninitialized';
35 $self->{path} .= '/' if $self->{path} eq $loc;
36 $self->{path} =~ s/^($loc)?\///;
43 my (%vars) = $self->{cgi}->Vars;
44 while ( my ( $key, $value ) = each %vars ) {
45 my @values = split "\0", $value;
46 $vars{$key} = @values <= 1 ? $values[0] : \@values;
48 $self->{params} = {%vars};
49 $self->{query} = {%vars};
55 # Collect HTTP headers
57 -type => $r->{content_type},
58 -charset => $r->{document_encoding},
59 -content_length => do { use bytes; length $r->{output} },
61 foreach ($r->headers_out->header_field_names) {
62 next if /^Content-(Type|Length)/;
63 $headers{"-$_"} = $r->headers_out->get($_);
66 print $r->{cgi}->header(%headers), $r->{output};
69 sub get_template_root {
71 $r->{cgi}->document_root . "/" . $r->{cgi}->url( -relative => 1 );
78 CGI::Maypole - CGI-based front-end to Maypole
83 use base 'CGI::Maypole';
84 BeerDB->setup("dbi:mysql:beerdb");
85 BeerDB->config->uri_base("http://your.site/cgi-bin/beer.cgi/");
86 BeerDB->config->display_tables([qw[beer brewery pub style]]);
87 BeerDB->config->template_root("/var/www/beerdb/");
88 # Now set up your database:
101 Now to access the beer database, type this URL into your browser:
102 http://your.site/cgi-bin/beer.cgi/frontpage
106 This is a handler for Maypole which will use the CGI instead of Apache's
107 C<mod_perl> 1.x. This handler can also be used for Apache 2.0.
115 Call this from your CGI script to start the Maypole application.
119 =head1 Implementation
121 This class overrides a set of methods in the base Maypole class to provide it's
122 functionality. See L<Maypole> for these:
128 =item get_template_root
140 Dave Ranney C<dave@sialia.com>
142 Simon Cozens C<simon@cpan.org>