Kelp
view release on metacpan or search on metacpan
lib/Kelp/Less.pm view on Meta::CPAN
package Kelp::Less;
use Kelp;
use Kelp::Base -strict;
our @EXPORT = qw/
app
attr
config
del
debug
error
get
module
named
param
post
put
req
res
route
run
session
stash
template
view
/;
our $app;
sub import
{
my $class = shift;
my $caller = caller;
no strict 'refs';
for my $sub (@EXPORT) {
*{"${caller}::$sub"} = eval("\\\&$sub");
}
strict->import;
warnings->import;
feature->import(':5.10');
$app = Kelp->new(config_module => 'Config::Less', @_);
$app->routes->base('main');
}
sub route
{
my ($path, $to) = @_;
$app->add_route($path, $to);
}
sub get
{
my ($path, $to) = @_;
route ref($path) ? $path : [GET => $path], $to;
}
sub post
{
my ($path, $to) = @_;
route ref($path) ? $path : [POST => $path], $to;
}
sub put
{
my ($path, $to) = @_;
route ref($path) ? $path : [PUT => $path], $to;
}
sub del
{
my ($path, $to) = @_;
route ref($path) ? $path : [DELETE => $path], $to;
}
sub run
{
# If we're running a test, then return the entire app,
# otherwise return the PSGI subroutine
return $ENV{KELP_TESTING} ? $app : $app->run;
}
sub app { $app }
sub attr { Kelp::Base::attr(ref($app), @_) }
sub param { $app->param(@_) }
sub session { $app->session(@_) }
sub stash { $app->stash(@_) }
sub named { $app->named(@_) }
sub req { $app->req }
sub res { $app->res }
sub template { $app->res->template(@_) }
sub view { $app->res->template(@_) }
sub debug { $app->debug(@_) if $app->can('debug') }
sub error { $app->error(@_) if $app->can('error') }
sub module { $app->load_module(@_) }
sub config { $app->config(@_) }
( run in 1.887 second using v1.01-cache-2.11-cpan-140bd7fdf52 )