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

PSGI::OR::CGI - Write a PSGI app that also runs as CGI

VERSION

$Id: CGI.pm,v 0.3 2010/09/09 09:21:14 dankogai Exp dankogai $

SYNOPSIS

  #!/usr/bin/env perl
  # printenv.(psgi|cgi)
  use strict;
  use warnings;
  use Data::Dumper;
  use PSGI::OR::CGI;
  
  my $app = sub {
    my $env = shift;
    return [ 200, [ 'Content-Type' => 'text/plain' ], [ Dumper($env) ] ];
  };
  
  PSGI::OR::CGI->run($app);
  # or Plack::Loader->auto->run($app) if you have Plack installed

EXPORT

None.

METHODS

PSGI::OR::CGI->run($app)

If CGI, prints response accordingly to PSGI. If PSGI, immediately returns $app

It checks the presense of $ENV{GATEWAY_INTERFACE} to check if the script is invoked as PSGI or CGI (or mod_perl Registry which also sets this environment variable).

use Plack::Loader; # instead if you have Plack installed

If you have Plack installed, you should use Plack::Loader instead as:

  use Plack::Loader;
  my $app = sub {
    ...
  };
  Plack::Loader->auto($app);

It is more comprehensive.

AUTHOR

Dan Kogai, <dankogai+cpan at gmail.com>

BUGS

Please report any bugs or feature requests to bug-psgi-or-cgi at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PSGI-OR-CGI. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc PSGI::OR::CGI

You can also look for information at:

ACKNOWLEDGEMENTS

PSGI, Plack, Plack::Loader

LICENSE AND COPYRIGHT

Copyright 2010 Dan Kogai.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.