missing CONTRIBUTORS entry for ether
[catagits/Web-Simple.git] / lib / Web / Simple.pm
index 0dc06f1..2959bce 100644 (file)
@@ -132,6 +132,16 @@ so that perl will not attempt to load the application again even if
 
 is encountered in other code.
 
+One important thing to remember when using
+
+  NameOfApplication->run_if_script;
+
+At the end of your app is that this call will create an instance of your app
+for you automatically, regardless of context. An easier way to think of this
+would be if the method were more verbosely named
+
+ NameOfApplication->run_request_if_script_else_turn_coderef_for_psgi;
+
 =head1 DISPATCH STRATEGY
 
 L<Web::Simple> despite being straightforward to use, has a powerful system
@@ -205,7 +215,7 @@ cleverness). If you want to return a PSGI sub you have to wrap it into an
 array ref.
 
   sub dispatch_request {
-    [ sub { 
+    [ sub {
         my $respond = shift;
         # This is pure PSGI here, so read perldoc PSGI
     } ]
@@ -228,6 +238,22 @@ somewhere will convert it to something useful.  This allows:
     sub (/user/*) { $self->users->get($_[1]) },
   }
 
+An alternative to using prototypes to declare a match specification for a given
+route is to provide a Dancer like key-value list:
+
+  sub dispatch_request {
+    my $self = shift;
+    (
+      '.html' => sub { response_filter { $self->render_zoom($_[0]) } },
+      '/user/*' => sub { $self->users->get($_[1]) },
+      'POST + %*' => 'handle_post',
+    )
+  }
+
+This can be useful in situations where you are generating a dispatch table
+programmatically, where setting a subroutines protoype is difficult.  Note that
+in the example above, C<handle_post> is a method that would be called.
+
 to render a user object to HTML, if there is an incoming URL such as:
 
   http://myweb.org/user/111.html
@@ -240,7 +266,7 @@ This user object 'bubbles up' through all the wrapping middleware until it hits
 the C<response_filter> we defined, after which the return is converted to a
 true html response.
 
-However, two types of object are treated specially - a C<Plack::Component> object
+However, two types of objects are treated specially - a C<Plack::Component> object
 will have its C<to_app> method called and be used as a dispatcher:
 
   sub dispatch_request {
@@ -836,6 +862,10 @@ Andrew Rodland (hobbs) <andrew@cleverdomain.org>
 
 Robert Sedlacek (phaylon) <r.sedlacek@shadowcat.co.uk>
 
+Hakim Cassimally (osfameron) <osfameron@cpan.org>
+
+Karen Etheridge (ether) <ether@cpan.org>
+
 =head1 COPYRIGHT
 
 Copyright (c) 2011 the Web::Simple L</AUTHOR> and L</CONTRIBUTORS>