From 632c49ac803318063f600963e61efedfc869ca77 Mon Sep 17 00:00:00 2001 From: MaxPerl Date: Sat, 8 Jun 2019 23:43:08 +0200 Subject: [PATCH 1/2] Better documentation for psgi_app --- lib/CGI/Application.pm | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/CGI/Application.pm b/lib/CGI/Application.pm index 8e2d223..8cfbbf1 100644 --- a/lib/CGI/Application.pm +++ b/lib/CGI/Application.pm @@ -1078,12 +1078,36 @@ 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. +object, you have to construct your own object using C<< run_as_psgi() >>, +as shown below, because C<< psgi_app >> creates a new CGI::PSGI object +unconditionally on every request and therefore overrides a own query object. 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. +The use of psgi_app might look like this: + + package WebApp; + use base "CGI::Application"; + + sub setup { + my $self = shift; + $self->start_mode('welcome'); + $self->mode_param('rm'); + $self->run_modes( + 'welcome' => 'welcome' + ); + } + + sub welcome { + return "Hello World $q"; + } + + package main; + + my $app = WebApp->psgi_app(); + =head3 run_as_psgi() my $psgi_aref = $webapp->run_as_psgi; From 873b3eca134ee6eb79c5f368ffced33ccb9d4faa Mon Sep 17 00:00:00 2001 From: MaxPerl Date: Sat, 8 Jun 2019 23:45:28 +0200 Subject: [PATCH 2/2] Typo --- 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 8cfbbf1..f8e4c22 100644 --- a/lib/CGI/Application.pm +++ b/lib/CGI/Application.pm @@ -1101,7 +1101,7 @@ The use of psgi_app might look like this: } sub welcome { - return "Hello World $q"; + return "Hello World"; } package main;