The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Gantry::Engine::CGI - CGI plugin ( or mixin )

SYNOPSIS

 use strict;
 use CGI::Carp qw(fatalsToBrowser);
 use MyApp qw( -Engine=CGI -TemplateEngine=Default );
 use Gantry::Engine::CGI;

 my $cgi = Gantry::Engine::CGI->new( {
   locations => {
     '/'        => 'MyApp',
     '/music'  => 'MyApp::Music',
   },
   config => {
      img_rootp           => '/malcolm/images',
      css_rootp           => '/malcolm/style',
      app_rootp           => '/cgi-bin/theworld.cgi',
   }
 } );

 # optional: templating variables
 $cgi->add_config( 'template_wrapper', 'wrapper.tt' );
 $cgi->add_config( 'root', '/home/httpd/templates' );
  
 # optional: database connection variables
 $cgi->add_config( 'dbconn', 'dbi:Pg:dbname=mydatabase' );
 $cgi->add_config( 'dbuser','apache' );

 # optional: add another location
 $cgi->add_location( '/music/artists', 'MyApp::Music::Artists' );
 
 # Standard CGI 
 $cgi->dispatch;   

 # Fast-CGI
 use FCGI;
 my $request = FCGI::Request();
  
 while( $request->Accept() >= 0 ) {
   $cgi->dispatch;
 }

Fast-CGI

Be sure add the nesscessary while loop around the cgi dispatch method call.

 use FCGI;
 my $request = FCGI::Request();

 while( $request->Accept() >= 0 ) {
   $cgi->dispatch;
 }

Fast-CGI and Apache

To enable Fast-CGI for Apache goto http://www.fastcgi.com/

 Alias /cgi-bin/ "/home/httpd/cgi-bin/"
 <Location /cgi-bin>
     Options +ExecCGI
     AddHandler fastcgi-script cgi
 </Location>

DESCRIPTION

This module is the binding between the Gantry framework and the CGI API. This particluar module contains the standard CGI specific bindings.

METHODS of this CLASS

new

cgi object that can be used to dispatch request to corresonding

dispatch

This method dispatchs the current request to the corresponding module.

add_config

Adds a configuration item to the cgi object

add_location

Adds a location to the cgi object

METHODS MIXED into the SITE OBJECT

$self->base_server

Returns the physical server this connection came in on (main server or vhost):

dispatch_location

The uri tail specific to this request. Returns:

    $ENV{ PATH_INFO }, $self->config->location

Note that this a two element list.

engine

Returns the name for the engine

fish_config

Pass this method the name of a conf parameter you need. Returns the value for the parameter.

fish_location

Returns the location for the current request.

fish_method

Returns the HTTP method of the current request.

fish_path_info

Returns the path info for the current request.

fish_uri

Returns the uri for the current request.

fish_user

Returns the currently logged-in user.

$self->get_arg_hash

returns a hash of url arguments.

/some/where?arg1=don&arg2=johnson

get_config

If you are using Gantry::Conf, this will return the config hash reference for the current location.

get_cached_conf/set_cached_conf

These cache the Gantry::Conf config hash in a lexical hash. Override them if you want more persistent caching. These are instance methods. get receives the invoking object, the name of the GantryConfInstance, and the current location (for ease of use, its also in the invocant). set receives those plus the conf hash it should cache.

$self->header_out( $header_key, $header_value )

Change the value of a response header, or create a new one.

$self->remote_ip

Returns the IP address for the remote user

$self->port

Returns port number in which the request came in on.

$self->server_root

Returns the value set by the top-level ServerRoot directive

$self->status_const( 'OK | DECLINED | REDIRECT' )

Get or set the reply status for the client request. The Apache::Constants module provide mnemonic names for the status codes.

SEE ALSO

Gantry(3)

LIMITATIONS

AUTHOR

Tim Keefer <tkeefer@gmail.com>

COPYRIGHT and LICENSE

Copyright (c) 2005-6, Tim Keefer.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.

3 POD Errors

The following errors were encountered while parsing the POD:

Around line 799:

You forgot a '=back' before '=head1'

Around line 801:

'=item' outside of any '=over'

Around line 887:

You forgot a '=back' before '=head1'