Fastcgi applications superclass
# Run application MyFCGI->run(); 1; # Application package itself package MyFCGI; use base 'NetSDS::App::FCGI'; sub process { my ($self) = @_; $self->data('Hello World'); $self->mime('text/plain'); $self->charset('utf-8'); }
\*(C`NetSDS::App::FCGI\*(C' module contains superclass for FastCGI applications. This class is based on \*(C`NetSDS::App\*(C' module and inherits all its functionality like logging, configuration processing, etc.
Normally constructor of application framework shouldn't be invoked directly.
my $https_header = $self->cgi->https('X-Some-Header');
Paramters: new status to set Returns: response status value $self->status('200 OK');
Paramters: new \s-1MIME\s0 type for response $self->mime('text/xml'); # output will be XML data
$self->mime('text/plain'); $self->charset('koi8-r'); # ouput as KOI8-R text
Paramters: new data \*(L"as is\*(R" $self->mime('text/plain'); $self->data('Hello world!');
Paramters: new \s-1URL\s0 (relative or absolute) This method send reponse with 302 status and new location. if (havent_data()) { $self->redirect('http://www.google.com'); # to google! };
Paramters: Returns: This method provides.....
Paramters: new headers as hash reference $self->headers({ 'X-Beer' => 'Guiness', );
Paramters: none This method implements common FastCGI (or \s-1CGI\s0) loop.
Paramters: hash (name, value, expires) $self->set_cookie(name => 'sessid', value => '343q5642653476', expires => '+1h');
Paramters: cookie name Returns cookie value by it's name my $sess = $self->get_cookie('sessid');
Paramters: \s-1CGI\s0 parameter name Returns: \s-1CGI\s0 parameter value This method returns \s-1CGI\s0 parameter value by it's name. my $cost = $self->param('cost');
Paramters: \s-1URL\s0 parameter name Returns: \s-1URL\s0 parameter value This method works similar to param() method, but returns only parameters from the query string. my $action = $self->url_param('a');
Paramters: request header name Returns: header value This method returns \s-1HTTP\s0 request header value by name. my $beer = $self->http('X-Beer');
This method returns \s-1HTTPS\s0 request header value by name and is almost the same as http() method except of it works with \s-1SSL\s0 requests. my $beer = $self->https('X-Beer');
Just proxying \*(C`raw_cookie()\*(C' method from \s-1CGI\s0.pm
my $ua_info = $self->user_agent();
if ($self->request_method eq 'POST') { $self->log("info", "Something POST'ed from client"); }
Returns: script name from \s-1CGI\s0.pm
if ($self->path_info eq '/help') { $self->data('Help yourself'); }
warn "Client from: " . $self->remote_host();
Returns: \s-1IP\s0 address of client from \s-1REMOTE_ADDR\s0 environment if ($self->remote_addr eq '10.0.0.1') { $self->data('Welcome people from our gateway!'); }
Fetching cookies from \s-1HTTP\s0 request to object \*(C`req_cookies\*(C' variable.
See \*(C`samples\*(C' catalog for more example code.
\s-1CGI\s0, CGI::Fast, NetSDS::App
Michael Bochkaryov <[email protected]>
Copyright (C) 2008-2009 Net Style Ltd.
This program is free software; you can redistribute it and/or modify it under the terms of the \s-1GNU\s0 General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0; without even the implied warranty of \s-1MERCHANTABILITY\s0 or \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. See the \s-1GNU\s0 General Public License for more details.
You should have received a copy of the \s-1GNU\s0 General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, \s-1MA\s0 02111-1307 \s-1USA\s0