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->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
104 NOTE: this Maypole frontend requires additional modules that won't be installed or included with Maypole. Please see below.
108 This is a CGI platform driver for Maypole. Your application can inherit from
109 CGI::Maypole directly, but it is recommended that you use
110 L<Maypole::Application>.
112 This module requires CGI::Simple which you will have to install yourself via CPAN or manually.
120 Call this from your CGI script to start the Maypole application.
124 =head1 Implementation
126 This class overrides a set of methods in the base Maypole class to provide it's
127 functionality. See L<Maypole> for these:
133 =item get_template_root
149 Dave Ranney C<dave@sialia.com>
151 Simon Cozens C<simon@cpan.org>