• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

inc/Module/H17-May-2011-2,1421,599

lib/CGI/H17-May-2011-334167

t/H17-May-2011-427322

tools/H17-May-2011-1512

xt/H17-May-2011-2622

.gitignoreH A D25-Sep-200937 65

ChangesH A D17-May-20111.7 KiB4732

MANIFESTH A D17-May-2011544 3029

META.ymlH A D17-May-2011612 2928

Makefile.PLH A D10-Nov-2010183 118

READMEH A D11-Nov-20103 KiB8963

README

1NAME
2    CGI::PSGI - Adapt CGI.pm to the PSGI protocol
3
4SYNOPSIS
5      use CGI::PSGI;
6
7      my $app = sub {
8          my $env = shift;
9          my $q = CGI::PSGI->new($env);
10          return [ $q->psgi_header, [ $body ] ];
11      };
12
13DESCRIPTION
14    This module is for web application framework developers who currently
15    uses CGI to handle query parameters, and would like for the frameworks
16    to comply with the PSGI protocol.
17
18    Only slight modifications should be required if the framework is already
19    collecting the body content to print to STDOUT at one place (rather
20    using the print-as-you-go approach).
21
22    On the other hand, if you are an "end user" of CGI.pm and have a CGI
23    script that you want to run under PSGI web servers, this module might
24    not be what you want. Take a look at CGI::Emulate::PSGI instead.
25
26    Your application, typically the web application framework adapter should
27    update the code to do "CGI::PSGI->new($env)" instead of "CGI->new" to
28    create a new CGI object. (This is similar to how CGI::Fast object is
29    initialized in a FastCGI environment.)
30
31INTERFACES SUPPORTED
32    Only the object-oriented interface of CGI.pm is supported through
33    CGI::PSGI. This means you should always create an object with
34    "CGI::PSGI->new($env)" and should call methods on the object.
35
36    The function-based interface like "use CGI ':standard'" does not work
37    with this module.
38
39METHODS
40    CGI::PSGI adds the following extra methods to CGI.pm:
41
42  env
43      $env = $cgi->env;
44
45    Returns the PSGI environment in a hash reference. This allows
46    CGI.pm-based application frameworks such as CGI::Application to access
47    PSGI extensions, typically set by Plack Middleware components.
48
49    So if you enable Plack::Middleware::Session, your application and plugin
50    developers can access the session via:
51
52      $cgi->env->{'plack.session'}->get("foo");
53
54    Of course this should be coded carefully by checking the existence of
55    "env" method as well as the hash key "plack.session".
56
57  psgi_header
58     my ($status_code, $headers_aref) = $cgi->psgi_header(%args);
59
60    Works like CGI.pm's header(), but the return format is modified. It
61    returns an array with the status code and arrayref of header pairs that
62    PSGI requires.
63
64    If your application doesn't use "$cgi->header", you can ignore this
65    method and generate the status code and headers arrayref another way.
66
67  psgi_redirect
68     my ($status_code, $headers_aref) = $cgi->psgi_redirect(%args);
69
70    Works like CGI.pm's redirect(), but the return format is modified. It
71    returns an array with the status code and arrayref of header pairs that
72    PSGI requires.
73
74    If your application doesn't use "$cgi->redirect", you can ignore this
75    method and generate the status code and headers arrayref another way.
76
77AUTHOR
78    Tatsuhiko Miyagawa <miyagawa@bulknews.net>
79
80    Mark Stosberg <mark@summersault.com>
81
82LICENSE
83    This library is free software; you can redistribute it and/or modify it
84    under the same terms as Perl itself.
85
86SEE ALSO
87    CGI, CGI::Emulate::PSGI
88
89