X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FWeb%2FSimple.pm;h=70bb97fdb8dc7370a4b4a514d75ba59bb72a8419;hb=d57f3db440f7140beaebc64a77e34cbab14427e6;hp=1e350e03743f76780b0fe8d430a23552c489fa61;hpb=cb12d2a32b35b292b35a9146d55a11f86db87954;p=catagits%2FWeb-Simple.git diff --git a/lib/Web/Simple.pm b/lib/Web/Simple.pm index 1e350e0..70bb97f 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.008'; +our $VERSION = '0.010'; sub import { my ($class, $app_package) = @_; @@ -39,18 +39,15 @@ Web::Simple - A quick and easy way to build simple web applications #!/usr/bin/env perl - use Web::Simple 'HelloWorld'; + package HelloWorld; + use Web::Simple - { - package HelloWorld; - - sub dispatch_request { - sub (GET) { - [ 200, [ 'Content-type', 'text/plain' ], [ 'Hello world!' ] ] - }, - sub () { - [ 405, [ 'Content-type', 'text/plain' ], [ 'Method not allowed' ] ] - } + sub dispatch_request { + sub (GET) { + [ 200, [ 'Content-type', 'text/plain' ], [ 'Hello world!' ] ] + }, + sub () { + [ 405, [ 'Content-type', 'text/plain' ], [ 'Method not allowed' ] ] } } @@ -60,9 +57,17 @@ If you save this file into your cgi-bin as C and then visit: http://my.server.name/cgi-bin/hello-world.cgi/ -you'll get the "Hello world!" string output to your browser. For more complex -examples and non-CGI deployment, see below. To get help with L, -please connect to the irc.perl.org IRC network and join #web-simple. +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. =head1 DESCRIPTION @@ -82,7 +87,7 @@ C based one: This sets up your package (in this case "NameOfApplication" is your package) so that it inherits from L and imports L, -as well as installs a C constant for convenience, as well as some +as well as installs a C constant for convenience, as well as some other subroutines. Importing L will automatically make your code use the C and @@ -426,7 +431,7 @@ the 'coffee' parameter. Note, in the case where you combine arrayref, single parameter and named hashref style, the arrayref and single parameters will appear in C<@_> in the -order you defined them in the protoype, but all hashrefs will merge into a +order you defined them in the protoype, but all hashrefs will merge into a single C<$params>, as in the example above. =head3 Upload matches (EXPERIMENTAL) @@ -572,7 +577,7 @@ Thus if you receive a POST to '/some/url' and return a redispatch to request had been made to '/other/url' instead. Note, this is not the same as returning an HTTP 3xx redirect as a response; -rather it is a much more efficient internal process. +rather it is a much more efficient internal process. =head1 CHANGES BETWEEN RELEASES @@ -623,6 +628,8 @@ As of 0.005, you can instead write simply: ) } +=back + =head2 Changes since Antiquated Perl =over 4 @@ -674,11 +681,31 @@ Gitweb is on http://git.shadowcat.co.uk/ and the clone URL is: =head1 AUTHOR -Matt S. Trout +Matt S. Trout (mst) =head1 CONTRIBUTORS -None required yet. Maybe this module is perfect (hahahahaha ...). +Devin Austin (dhoss) + +Arthur Axel 'fREW' Schmidt + +gregor herrmann (gregoa) + +John Napiorkowski (jnap) + +Josh McMichael + +Justin Hunter + +Kjetil Kjernsmo + +markie + +Christian Walde (Mithaldu) + +nperez + +Robin Edwards =head1 COPYRIGHT