};
$output .= $query->end_html();
From ad2ab5f25e2084b3dfe65c7e1552874f05ad57a2 Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Fri, 23 Jan 2015 10:28:32 +0000
Subject: [PATCH 06/29] Add bugtracker URL
---
Build.PL | 1 +
1 file changed, 1 insertion(+)
diff --git a/Build.PL b/Build.PL
index 324d320..82992f8 100644
--- a/Build.PL
+++ b/Build.PL
@@ -29,6 +29,7 @@ my $build = Module::Build->new
meta_merge => {
resources => {
repository => 'https://github.com/MartinMcGrath/CGI--Application',
+ bugtracker => 'https://github.com/MartinMcGrath/CGI--Application/issues'
},
},
);
From 96955df695f7bda4831ab977ee02da8cc4d7768f Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Fri, 23 Jan 2015 11:16:19 +0000
Subject: [PATCH 07/29] Bump version number to 4.50_50
---
lib/CGI/Application.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/CGI/Application.pm b/lib/CGI/Application.pm
index a697b80..330f5b4 100644
--- a/lib/CGI/Application.pm
+++ b/lib/CGI/Application.pm
@@ -4,7 +4,7 @@ use strict;
use Class::ISA;
use Scalar::Util;
-$CGI::Application::VERSION = '4.50_';
+$CGI::Application::VERSION = '4.50_50';
my %INSTALLED_CALLBACKS = (
# hook name package sub
From b62b501424589ff9f2fb06afab4693ca56d3b441 Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Fri, 23 Jan 2015 11:37:34 +0000
Subject: [PATCH 08/29] Update AUTHORS
---
lib/CGI/Application.pm | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/CGI/Application.pm b/lib/CGI/Application.pm
index 330f5b4..15034ae 100644
--- a/lib/CGI/Application.pm
+++ b/lib/CGI/Application.pm
@@ -2572,8 +2572,9 @@ they provide to the Perl community!
Jesse Erlbaum
-Mark Stosberg has served as a co-maintainer since version 3.2, with the help of
-the numerous contributors documented in the Changes file.
+Mark Stosberg has served as a co-maintainer since version 3.2, Martin McGrath
+became a co-maintainer as of version 4.51, with the help of the numerous
+contributors documented in the Changes file.
=head1 CREDITS
From 8ab7b0fe3a68c7e9b581f74d054677f59bd7f84b Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Fri, 23 Jan 2015 12:02:53 +0000
Subject: [PATCH 09/29] Add changes for 4.50_50 developer release
---
Changes | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/Changes b/Changes
index ab160b6..b35918b 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,14 @@
Revision history for CGI::Application.
+4.50_50 (developer releae) Fri Jun 23, 2014
+
+ [BUGS]
+ Fixed rt #84403 - Security problem: missing "start" mode dumps ENV to output page. (Martin McGrath)
+ Ensure dump_html() returns valid HTML. (Martin McGrath)
+
+ [DOCUMENTATION]
+ - Changes to repository URL and bugtracker. Added Martin McGrath as a co-maintainer
+
4.50 Thu Jun 16, 2011
[FEATURES]
From de44de393fca7d7a657e258eed82940a2e72024e Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Fri, 23 Jan 2015 14:23:15 +0000
Subject: [PATCH 10/29] Formatting
---
Changes | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Changes b/Changes
index b35918b..fe2fab7 100644
--- a/Changes
+++ b/Changes
@@ -7,7 +7,7 @@ Revision history for CGI::Application.
Ensure dump_html() returns valid HTML. (Martin McGrath)
[DOCUMENTATION]
- - Changes to repository URL and bugtracker. Added Martin McGrath as a co-maintainer
+ Changes to repository URL and bugtracker. Added Martin McGrath as a co-maintainer
4.50 Thu Jun 16, 2011
From 4a3245c9a7b3db2eaee53311fbdf3dd059bf166a Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Thu, 29 Jan 2015 11:37:08 +0000
Subject: [PATCH 11/29] List formatting
---
Changes | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Changes b/Changes
index fe2fab7..cbe3283 100644
--- a/Changes
+++ b/Changes
@@ -3,11 +3,11 @@ Revision history for CGI::Application.
4.50_50 (developer releae) Fri Jun 23, 2014
[BUGS]
- Fixed rt #84403 - Security problem: missing "start" mode dumps ENV to output page. (Martin McGrath)
- Ensure dump_html() returns valid HTML. (Martin McGrath)
+ - Fixed rt #84403 - Security problem: missing "start" mode dumps ENV to output page. (Martin McGrath)
+ - Ensure dump_html() returns valid HTML. (Martin McGrath)
[DOCUMENTATION]
- Changes to repository URL and bugtracker. Added Martin McGrath as a co-maintainer
+ - Changes to repository URL and bugtracker. Added Martin McGrath as a co-maintainer
4.50 Thu Jun 16, 2011
From 064a44ede369454b1527582646f7db7c06c58202 Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Mon, 16 Feb 2015 13:32:47 +0000
Subject: [PATCH 12/29] Fix release note for 4.50_50
Add notes for older commits.
---
Changes | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/Changes b/Changes
index cbe3283..08608e3 100644
--- a/Changes
+++ b/Changes
@@ -1,13 +1,17 @@
Revision history for CGI::Application.
-4.50_50 (developer releae) Fri Jun 23, 2014
+4.50_50 (developer release) Fri Jun 23, 2014
+
+ - Add PSGI Streaming methods (Mike Tonks)
+ - Added CGI.pm dependency, it is no longer a core module (Martin McGrath)
[BUGS]
- Fixed rt #84403 - Security problem: missing "start" mode dumps ENV to output page. (Martin McGrath)
- Ensure dump_html() returns valid HTML. (Martin McGrath)
[DOCUMENTATION]
- - Changes to repository URL and bugtracker. Added Martin McGrath as a co-maintainer
+ - Changes to repository URL and bug tracker, added Martin McGrath as a co-maintainer
+ - Typo fixes (David Steinbrunner)
4.50 Thu Jun 16, 2011
From 0488c0438b536b37f253a94c119b251d83e84b36 Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Mon, 16 Feb 2015 16:09:11 +0000
Subject: [PATCH 13/29] Ready 4.51
---
Changes | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Changes b/Changes
index 08608e3..2fd23a1 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
Revision history for CGI::Application.
+4.51
+
+ No changes from 4.50_50 developer release
+
4.50_50 (developer release) Fri Jun 23, 2014
- Add PSGI Streaming methods (Mike Tonks)
From 433f8eccabd3579f95bb138455a63f36d2e11c69 Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Tue, 3 Mar 2015 16:00:33 +0000
Subject: [PATCH 14/29] Add Scalar::Util to requires
Add Scalar::Util to requires, See https://github.com/MartinMcGrath/CGI--Application/commit/5a135b01090031a8018330b07ad8e479c33617d9
---
Build.PL | 1 +
1 file changed, 1 insertion(+)
diff --git a/Build.PL b/Build.PL
index 82992f8..5683368 100644
--- a/Build.PL
+++ b/Build.PL
@@ -11,6 +11,7 @@ my $build = Module::Build->new
'Test::Requires' => 0,
'Carp' => 0,
'Class::ISA' => 0,
+ 'Scalar::Util' => 0,
},
recommends => {
CGI::PSGI => 0.09, # If you want to use run_as_psgi()
From 1f9b1541050b11dd91bb372a45cbdbba411d1cce Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Thu, 25 Jun 2015 08:58:27 +0000
Subject: [PATCH 15/29] Add .travis.yml for testing
---
.travis.yml | 11 +++++++++++
1 file changed, 11 insertions(+)
create mode 100644 .travis.yml
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..e88d915
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,11 @@
+language: perl
+before_install:
+ - cpanm --notest CGI HTML::Template
+perl:
+ - "5.20"
+ - "5.18"
+ - "5.16"
+ - "5.14"
+ - "5.12"
+ - "5.10"
+ - "5.8"
From fa98c992feb9790a5f1cbd7e6cb1f993d67ae97c Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Wed, 15 Jul 2015 13:40:01 +0000
Subject: [PATCH 16/29] Merge changes required for new CGI.pm warnings, PSGI
commits. Add other perl versions to .travis.yml
---
.travis.yml | 2 +-
lib/CGI/Application.pm | 12 +++++++-----
t/lib/TestApp14.pm | 2 +-
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index e88d915..4a5137c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,6 @@
language: perl
before_install:
- - cpanm --notest CGI HTML::Template
+ - cpanm --notest CGI HTML::Template CGI::PSGI
perl:
- "5.20"
- "5.18"
diff --git a/lib/CGI/Application.pm b/lib/CGI/Application.pm
index 15034ae..9251bba 100644
--- a/lib/CGI/Application.pm
+++ b/lib/CGI/Application.pm
@@ -243,11 +243,12 @@ sub psgi_app {
return sub {
my $env = shift;
-
- if (not defined $args_to_new->{QUERY}) {
+
+ # PR from alter https://github.com/markstos/CGI--Application/pull/17
+ #if (not defined $args_to_new->{QUERY}) {
require CGI::PSGI;
$args_to_new->{QUERY} = CGI::PSGI->new($env);
- }
+ #}
my $webapp = $class->new($args_to_new);
return $webapp->run_as_psgi;
@@ -332,10 +333,11 @@ sub dump {
$output .= "Current Run mode: '$current_runmode'\n";
# Dump Params
+ # updated ->param to ->multi_param to silence CGI.pm warning
$output .= "\nQuery Parameters:\n";
- my @params = $self->query->param();
+ my @params = $self->query->multi_param();
foreach my $p (sort(@params)) {
- my @data = $self->query->param($p);
+ my @data = $self->query->multi_param($p);
my $data_str = "'".join("', '", @data)."'";
$output .= "\t$p => $data_str\n";
}
diff --git a/t/lib/TestApp14.pm b/t/lib/TestApp14.pm
index 40ef997..d209112 100644
--- a/t/lib/TestApp14.pm
+++ b/t/lib/TestApp14.pm
@@ -13,7 +13,7 @@ sub start {
my $self = shift;
my $t = $self->load_tmpl('test.tmpl');
- $t->param(ping => $self->query->param('message'));
+ $t->param(ping => scalar $self->query->param('message'));
return $t->output();
}
From 4733c87ea705062cdd532b9d66a0f26ec025f90e Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Thu, 16 Jul 2015 10:42:18 +0000
Subject: [PATCH 17/29] Add README in markdown format
---
README.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
create mode 100644 README.md
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..38caaf1
--- /dev/null
+++ b/README.md
@@ -0,0 +1,55 @@
+# CGI::Application - Framework for building reusable web-applications
+
+
+
+CGI::Application is intended to make it easier to create sophisticated,
+reusable web-based applications. This module implements a methodology which,
+if followed, will make your web software easier to design, easier to
+document, easier to write, and easier to evolve.
+
+Download site for CGI::Application:
+
+ http://search.cpan.org/dist/CGI-Application/
+
+See the 'Changes' file for recent changes.
+
+For more information about this module, please see our website at:
+
+http://www.cgi-app.org/
+
+#### How do I install it?
+
+To install this module, cd to the directory that contains this README
+file and type the following:
+
+```
+perl Makefile.PL
+make
+make test
+make install
+```
+
+CGI::Application builds on standard, non-proprietary technologies and
+techniques, such as the Common Gateway Interface and Lincoln D. Stein's
+excellent CGI.pm module. CGI::Application judiciously avoids employing
+technologies and techniques which would bind a developer to any one set
+of tools, operating system or web server.
+
+The guiding philosophy behind CGI::Application is that a web-based
+application can be organized into a specific set of "Run Modes." Each
+Run Mode is roughly analogous to a single screen (a form, some output, etc).
+All the Run Modes are managed by a single "Application Module" which is a
+Perl module. In your web server's document space there is an "Instance
+Script" which is called by the web server as a CGI (or an Apache::Registry
+script if you're using Apache + mod_perl).
+
+CGI::Application is an Object-Oriented Perl module which implements an
+Abstract Class. It is not intended that this package be instantiated
+directly. Instead, it is intended that your Application Module will be
+implemented as a Sub-Class of CGI::Application.
+
+If you have any questions, comments, bug reports or feature suggestions,
+post them to the support mailing list! To join the mailing list, simply
+send a blank message to "cgiapp-subscribe@lists.erlbaum.net".
+
+We also have an IRC channel named #cgiapp on irc.perl.org.
From 997dde9b7f6f4a48ffc13fd01de0c07286e2082b Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Thu, 16 Jul 2015 15:12:39 +0000
Subject: [PATCH 18/29] Prepare new development release
---
Changes | 8 ++++++--
README.md | 2 +-
lib/CGI/Application.pm | 2 +-
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/Changes b/Changes
index 2fd23a1..25e40cf 100644
--- a/Changes
+++ b/Changes
@@ -1,8 +1,12 @@
Revision history for CGI::Application.
-4.51
+4.50.51 2015-07-16
- No changes from 4.50_50 developer release
+ [BUGS]
+ - Create new CGI::PSGI object unconditionally in psgi_app()/Bug #88506 (allter)
+
+ [DOCUMENTATION]
+ - Introduced Travis CI (Martin McGrath)
4.50_50 (developer release) Fri Jun 23, 2014
diff --git a/README.md b/README.md
index 38caaf1..49e2097 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ http://www.cgi-app.org/
#### How do I install it?
-To install this module, cd to the directory that contains this README
+To install this module, `cd` to the directory that contains this README
file and type the following:
```
diff --git a/lib/CGI/Application.pm b/lib/CGI/Application.pm
index 9251bba..a6da533 100644
--- a/lib/CGI/Application.pm
+++ b/lib/CGI/Application.pm
@@ -4,7 +4,7 @@ use strict;
use Class::ISA;
use Scalar::Util;
-$CGI::Application::VERSION = '4.50_50';
+$CGI::Application::VERSION = '4.50_51';
my %INSTALLED_CALLBACKS = (
# hook name package sub
From 52fc327e71817b88cd8ccaeb803c0904e7215a1a Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Sat, 18 Jul 2015 13:01:24 +0000
Subject: [PATCH 19/29] Update Changes: Mark _51 as a developer release
---
Changes | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Changes b/Changes
index 25e40cf..f37cd3c 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,6 @@
Revision history for CGI::Application.
-4.50.51 2015-07-16
+4.50.51 (developer release) 2015-07-16
[BUGS]
- Create new CGI::PSGI object unconditionally in psgi_app()/Bug #88506 (allter)
From e0463bd58f3ce1e684f41ea7af68c7f459319031 Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Mon, 20 Jul 2015 11:00:43 +0000
Subject: [PATCH 20/29] Update .travis.yml - Add v5.22, 5.23
---
.travis.yml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.travis.yml b/.travis.yml
index 4a5137c..ea25be0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,6 +2,8 @@ language: perl
before_install:
- cpanm --notest CGI HTML::Template CGI::PSGI
perl:
+ = "5.23":
+ - "5.22"
- "5.20"
- "5.18"
- "5.16"
From 0e5d6e1ecdccde90610fb675ccd129b2e3b9adfe Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Mon, 20 Jul 2015 11:06:48 +0000
Subject: [PATCH 21/29] Fix typo
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index ea25be0..71ddb9a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,7 +2,7 @@ language: perl
before_install:
- cpanm --notest CGI HTML::Template CGI::PSGI
perl:
- = "5.23":
+ - "5.23"
- "5.22"
- "5.20"
- "5.18"
From dd6e57a2aba16a7e4f2be237c7fb72c1be5b5e72 Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Mon, 20 Jul 2015 11:15:36 +0000
Subject: [PATCH 22/29] Revert "Fix typo"
This reverts commit 0e5d6e1ecdccde90610fb675ccd129b2e3b9adfe.
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 71ddb9a..ea25be0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,7 +2,7 @@ language: perl
before_install:
- cpanm --notest CGI HTML::Template CGI::PSGI
perl:
- - "5.23"
+ = "5.23":
- "5.22"
- "5.20"
- "5.18"
From 9856ee071ec756b9d335640feb018bfb241e2989 Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Mon, 20 Jul 2015 11:15:52 +0000
Subject: [PATCH 23/29] Revert "Update .travis.yml - Add v5.22, 5.23"
This reverts commit e0463bd58f3ce1e684f41ea7af68c7f459319031.
---
.travis.yml | 2 --
1 file changed, 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index ea25be0..4a5137c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,8 +2,6 @@ language: perl
before_install:
- cpanm --notest CGI HTML::Template CGI::PSGI
perl:
- = "5.23":
- - "5.22"
- "5.20"
- "5.18"
- "5.16"
From 6559e37d91460378f4be6a85aae2463228d68eef Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Sun, 20 Nov 2016 08:50:29 +0000
Subject: [PATCH 24/29] switch to Travis-ci helpers
---
.travis.yml | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 4a5137c..1fdb92a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,11 +1,16 @@
language: perl
-before_install:
- - cpanm --notest CGI HTML::Template CGI::PSGI
perl:
+ - "5.22"
- "5.20"
- "5.18"
- "5.16"
- "5.14"
- "5.12"
- "5.10"
- - "5.8"
+ - "5.08"
+ - "5.06"
+ - "blead"
+sudo: false
+before_install:
+ - git clone git://github.com/travis-perl/helpers ~/travis-perl-helpers
+ - source ~/travis-perl-helpers/init --auto
\ No newline at end of file
From 35b407addde772025e115075fabdac1e0c5b1a63 Mon Sep 17 00:00:00 2001
From: Martin McGrath
Date: Sun, 20 Nov 2016 09:05:05 +0000
Subject: [PATCH 25/29] Fix travis typos, specifiy CGI version
---
.travis.yml | 4 ++--
Build.PL | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 1fdb92a..e7dab77 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,8 +7,8 @@ perl:
- "5.14"
- "5.12"
- "5.10"
- - "5.08"
- - "5.06"
+ - "5.8"
+ - "5.6"
- "blead"
sudo: false
before_install:
diff --git a/Build.PL b/Build.PL
index 5683368..b97d154 100644
--- a/Build.PL
+++ b/Build.PL
@@ -5,7 +5,7 @@ my $build = Module::Build->new
license => 'perl',
requires => {
'Module::Build' => 0,
- 'CGI' => 0,
+ 'CGI' => 4.21,
'HTML::Template' => 0,
'Test::More' => 0.47,
'Test::Requires' => 0,
From 46a3c98ba5b092c527754ca04984ae48ead92e35 Mon Sep 17 00:00:00 2001
From: MaxPerl
Date: Sun, 27 Nov 2016 23:09:30 +0100
Subject: [PATCH 26/29] Get $env easier with $self->env
Get $env easier with $self->env if CGI::Application is used as PSGI Application
---
lib/CGI/Application.pm | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/lib/CGI/Application.pm b/lib/CGI/Application.pm
index a6da533..246ea74 100644
--- a/lib/CGI/Application.pm
+++ b/lib/CGI/Application.pm
@@ -60,6 +60,11 @@ sub new {
if (exists($rprops->{QUERY})) {
$self->query($rprops->{QUERY});
}
+
+ # Set the ENV variable for PSGI Application
+ if (exists($rprops->{ENV})) {
+ $self->env($rprops->{ENV});
+ }
# Set up init param() values
if (exists($rprops->{PARAMS})) {
@@ -258,6 +263,8 @@ sub psgi_app {
sub run_as_psgi {
my $self = shift;
$self->{__IS_PSGI} = 1;
+ my $env = shift;
+ $self->env($env);
# Run doesn't officially support any args, but pass them through in case some sub-class uses them.
return $self->run(@_);
@@ -535,7 +542,17 @@ sub delete {
delete $self->{__PARAMS}->{$param};
}
-
+sub env {
+ my $self = shift;
+ my ($env) = @_;
+
+ # If data is provided, set it!
+ if (defined($env)) {
+ $self->{__ENV} = $env;
+ }
+
+ return $self->{__ENV};
+}
sub query {
my $self = shift;
my ($query) = @_;
From 22651c95ddcfa2fb647acae714bd4b0d32c4d272 Mon Sep 17 00:00:00 2001
From: MaxPerl
Date: Tue, 29 Nov 2016 20:19:18 +0100
Subject: [PATCH 27/29] Added pod Documentation
---
lib/CGI/Application.pm | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lib/CGI/Application.pm b/lib/CGI/Application.pm
index 246ea74..e1cc5fe 100644
--- a/lib/CGI/Application.pm
+++ b/lib/CGI/Application.pm
@@ -1035,6 +1035,11 @@ CGI::Application will instantiate its own CGI.pm query object.
Under certain conditions, it might be useful to be able to use
one which has already been created.
+B - This optional parameter allows you to save the PSGI environment hash.
+This is useful, because you can later get this environment hash in your Application
+Module with the method $self->env which could be important for using Plack::Middlewares
+and similiar.
+
B - This parameter, if used, allows you to set a number
of custom parameters at run-time. By passing in different
values in different instance scripts which use the same application
@@ -1101,7 +1106,7 @@ It's possible that we'll change from CGI::PSGI to a different-but-compatible
query object for PSGI support in the future, perhaps if CGI.pm adds native
PSGI support.
-=head3 run_as_psgi()
+=head3 run_as_psgi($env)
my $psgi_aref = $webapp->run_as_psgi;
@@ -1132,6 +1137,11 @@ PSGI spec. to handle the input, you need to use a CGI.pm-like query object that
is PSGI-compliant, such as L. This query object must provide L
and L methods.
+You can pass the PSGI enivornment hash as first argument to the run_as_psgi. This
+is the same as passing C<< {ENV => $env} >> to the method C<< new >> or C<< as_psgi >>.
+The benefit of this is that you can later in your Application Module easily access to this
+PSGI environment hash by C<< $self->env >>
+
The final result might look like this:
use WebApp;
From 32a888a7244ad54dc7964d24d204ab80fb5c373a Mon Sep 17 00:00:00 2001
From: MaxPerl
Date: Tue, 29 Nov 2016 20:27:34 +0100
Subject: [PATCH 28/29] Added patch and POD to psgi_app
---
lib/CGI/Application.pm | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/CGI/Application.pm b/lib/CGI/Application.pm
index e1cc5fe..117ad08 100644
--- a/lib/CGI/Application.pm
+++ b/lib/CGI/Application.pm
@@ -251,6 +251,7 @@ sub psgi_app {
# PR from alter https://github.com/markstos/CGI--Application/pull/17
#if (not defined $args_to_new->{QUERY}) {
+ $args_to_new->{ENV} = $env;
require CGI::PSGI;
$args_to_new->{QUERY} = CGI::PSGI->new($env);
#}
@@ -1099,8 +1100,10 @@ support to it.
The simplest way to create and return a PSGI-compatible coderef. Pass in
arguments to a hashref just as would to new. This returns a PSGI-compatible
-coderef, using L as the query object. To use a different query
-object, construct your own object using C<< run_as_psgi() >>, as shown below.
+coderef, using L as the query object and saving the PSGI
+environment hash in the key ENV so that it can be accesed with C<< $self->env >>.
+To use a different query object, construct your own object using C<< run_as_psgi() >>,
+as shown below.
It's possible that we'll change from CGI::PSGI to a different-but-compatible
query object for PSGI support in the future, perhaps if CGI.pm adds native
From a0c4fc7f0ceea94c63dc52b4a089e88156c1cb89 Mon Sep 17 00:00:00 2001
From: MaxPerl
Date: Fri, 2 Dec 2016 22:03:26 +0100
Subject: [PATCH 29/29] Complete Docs
---
lib/CGI/Application.pm | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lib/CGI/Application.pm b/lib/CGI/Application.pm
index 117ad08..6528b92 100644
--- a/lib/CGI/Application.pm
+++ b/lib/CGI/Application.pm
@@ -1578,6 +1578,16 @@ you can pass it to c like this:
$webapp->query($new_query_object);
my $q = $webapp->query(); # now uses $new_query_object
+=head3 env()
+
+ my $q = $webapp->env();
+ my $session = Plack::Session->new($env);
+
+This method retrieves the PSGI environment hash which has been created
+by instantiating your Application Module as a psgi script. This is important
+for using Plack::Middlewares, such as Plack::Middleware::Session in the
+example above.
+
=head3 run_modes()
# The common usage: an arrayref of run mode names that exactly match subroutine names