Limper::Sugar - sugary things like Dancer does
version 0.002
use Limper::Sugar; use Limper; # this must come after all extensions # routes limp;
Limper::Sugar extends Limper to have sugary things like in Dancer.
NOTE: this is all as yet untested.
USE OF THIS MODULE IS STRONGLY DISCOURAGED IN PUBLIC CODE. DO NOT USE IT IN A PLUGIN. It is meant to facilitate switching from Dancer. Consider everything in here deprecated. Some of these may end up in Limper proper at some point, while others offer no significant benefit. If you really feel it should be in Limper, make a request.
The following are all additionally exported by default:
limper_version load captures dirname halt send_error uri_for redirect content_type path
Returns the version of Limper in use.
Sugar around Perl's require, but can take a list of expressions to require.
Returns a copy of %+ (named capture groups) as a hashref.
%+
Exactly the same as "dirname" in File::Basename.
Prepends the request's X-Forwarded-Host or Host value to the path.
redirect $path, $status;
Sugar for the following, plus it will turn a Limper path into a URI.
status $status // 302; headers Location => uri_for $path;
Sugar for headers 'Content-Type' => $type. Note that this does not support abbreviated content types.
headers 'Content-Type' => $type
Sugar around "catfile" in File::Spec.
Merely returns @_.
Warning: In Dancer, this stops execution of the route. In Limper, there is currently no such mechanism. This may change in the future.
send_error $content, $status;
Sugar for the following:
status $status // 500; $content;
Copyright (C) 2014 by Ashley Willis <ashley+perl@gitable.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.12.4 or, at your option, any later version of Perl 5 you may have available.
Limper
To install Limper::Sugar, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Limper::Sugar
CPAN shell
perl -MCPAN -e shell install Limper::Sugar
For more information on module installation, please visit the detailed CPAN module installation guide.