Wurm::mob - Meal OBject. You asked.
use Wurm qw(mob); ... sub handler { my $meal = shift; $meal->log->({level => 'debug', message => 'Meal OBjects!'}); $meal->res->header('Content-Type', 'text/plain'); $meal->res->content('Hi, '. $meal->req->address. '!'); return $meal->res; } ...
Tired of crummy old HASHes in your request handlers? Upgrade them with the power of mob! There are two ways:
HASH
use Wurm::mob;
- or -
use Wurm qw(mob);
It wouldn't be correct to enable OO without adding some stuff! Here are some additions to the meal that each of your request handlers will enjoy:
meal
Set to a Plack::Request object created with the current $env. First class meals for first class requests. Can also be accessed with request().
Plack::Request
$env
request()
Set to a Plack::Response object wth the status set to 200. Provides a very convenient way to generate PSGI responses and finalize() will be called for you. Can also be accessed with response().
Plack::Response
finalize()
response()
The following accessors are provided for ease-of-abuse:
If mob is loaded, Wurm will automatically upgrade all incoming requests to use Wurm::mobs for all meals for all applications. For ever. If you need to turn this behavior off in a particular application, you can add mob => 0 to your folding ruleset and meals will remain a HASH.
Wurm::mob
mob => 0
jason hord <pravus@cpan.org>
This software is information. It is subject only to local laws of physics.
To install Wurm, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Wurm
CPAN shell
perl -MCPAN -e shell install Wurm
For more information on module installation, please visit the detailed CPAN module installation guide.