Skip to content
Browse files

improve .psgi files documentation

  • Loading branch information...
1 parent 7d06570 commit d7499e3e06ebe90c249e3eb8838595c847079523 @miyagawa miyagawa committed Feb 9, 2010
Showing with 38 additions and 3 deletions.
  1. +18 −1 README
  2. +20 −2 lib/Plack.pm
View
19 README
@@ -31,7 +31,24 @@ MODULES AND UTILITIES
reference in the command line or configuration files, so Plack uses a
convention that you need a file named "app.psgi" or alike, which would
be loaded (via perl's core function "do") to return the PSGI application
- code reference. See eg/dot-psgi directory for the example ".psgi" files.
+ code reference.
+
+ # Hello.psgi
+ my $app = sub {
+ my $env = shift;
+ # ...
+ return [ $status, $headers, $body ];
+ };
+
+ If you use a web framework, chances are that they provide a helper
+ utility to automatically generate these ".psgi" files for you, such as:
+
+ # MyApp.psgi
+ use MyApp;
+ my $app = sub { MyApp->run_psgi(@_) };
+
+ It's important that the return value of ".psgi" file is the code
+ reference. See eg/dot-psgi directory for more examples of ".psgi" files.
plackup, Plack::Runner
plackup is a command line launcher to run PSGI applications from command
View
22 lib/Plack.pm
@@ -49,8 +49,26 @@ PSGI application is a code reference but it's not easy to pass code
reference in the command line or configuration files, so Plack uses a
convention that you need a file named C<app.psgi> or alike, which
would be loaded (via perl's core function C<do>) to return the PSGI
-application code reference. See eg/dot-psgi directory for the example
-C<.psgi> files.
+application code reference.
+
+ # Hello.psgi
+ my $app = sub {
+ my $env = shift;
+ # ...
+ return [ $status, $headers, $body ];
+ };
+
+If you use a web framework, chances are that they provide a helper
+utility to automatically generate these C<.psgi> files for you, such
+as:
+
+ # MyApp.psgi
+ use MyApp;
+ my $app = sub { MyApp->run_psgi(@_) };
+
+It's important that the return value of C<.psgi> file is the code
+reference. See eg/dot-psgi directory for more examples of C<.psgi>
+files.
=head2 plackup, Plack::Runner

0 comments on commit d7499e3

Please sign in to comment.
Something went wrong with that request. Please try again.