-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved documentation for psgi_app #8
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<CGI:::PSGI> 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"; | ||
} | ||
|
||
package main; | ||
|
||
my $app = WebApp->psgi_app(); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that there's a need for this example here. The example I was talking about at #7 was essentially the one above: line |
||
=head3 run_as_psgi() | ||
|
||
my $psgi_aref = $webapp->run_as_psgi; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial version looked better IMHO. The only thing that should be added/highlighted is that
QUERY
parameter is not supported and will be overwritten.I would even add a warning / exception in the code if we detect that it was passed.