X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FWeb%2FSimple.pm;h=db835352a36f75acbd89b3aa629d5053004841c9;hb=1d02a8aebbc947b2ee87cfe8b65c01b8a942f99c;hp=b37ca273c8bcb1ad737f78e4c909fd7bc7ac4388;hpb=38d5b336fd21e01914a068ad1c8ac7ae6e4f1424;p=catagits%2FWeb-Simple.git diff --git a/lib/Web/Simple.pm b/lib/Web/Simple.pm index b37ca27..db83535 100644 --- a/lib/Web/Simple.pm +++ b/lib/Web/Simple.pm @@ -6,7 +6,7 @@ use warnings::illegalproto (); use Moo (); use Web::Dispatch::Wrapper (); -our $VERSION = '0.009'; +our $VERSION = '0.011'; sub import { my ($class, $app_package) = @_; @@ -61,6 +61,10 @@ you'll get the "Hello world!" string output to your browser. At the same time this file will also act as a class module, so you can save it as HelloWorld.pm and use it as-is in test scripts or other deployment mechanisms. +Note that you should retain the ->run_if_script even if your app is a +module, since this additionally makes it valid as a .psgi file, which can +be extremely useful during development. + For more complex examples and non-CGI deployment, see L. To get help with L, please connect to the irc.perl.org IRC network and join #web-simple. @@ -194,6 +198,17 @@ However, generally, instead of that, you return a set of dispatch subs: ... } +Well, a sub is a valid PSGI response too (for ultimate streaming and async +cleverness). If you want to return a PSGI sub you have to wrap it into an +array ref. + + sub dispatch_request { + [ sub { + my $respond = shift; + # This is pure PSGI here, so read perldoc PSGI + } ] + } + If you return a subroutine with a prototype, the prototype is treated as a match specification - and if the test is passed, the body of the sub is called as a method any matched arguments (see below for more details). @@ -307,9 +322,9 @@ also match more than one part: and so on. To match an arbitrary number of parts, use - sub (/page/**) { + my ($self, $match) = @_; -This will result in an element per /-separated part so matched. Note that -you can do +This will result in a single element for the entire match. Note that you can do sub (/page/**/edit) { @@ -691,7 +706,7 @@ John Napiorkowski (jnap) Josh McMichael -Justin Hunter +Justin Hunter (arcanez) Kjetil Kjernsmo @@ -705,7 +720,7 @@ Robin Edwards =head1 COPYRIGHT -Copyright (c) 2010 the Web::Simple L and L +Copyright (c) 2011 the Web::Simple L and L as listed above. =head1 LICENSE