Limper - extremely lightweight but not very powerful web application framework
Version 0.001
use Limper; my $generic = sub { 'yay' }; get '/' => $generic; post '/' => $generic; post qr{^/foo/} => sub { status 202, 'whatevs'; headers Foo => 'bar', Fizz => 'buzz'; 'you posted something: ' . request->{body}; }; limp;
Limper is designed primarily to be a simple HTTP/1.1 test server in perl. It has a simple syntax like Dancer, but no dependencies at all (expect for the tests), unlike the dozens that Dancer pulls in. It also does little to no processing of requests nor formatting of responses. This is by design, othewise, just use Dancer.
Limper
The following are all exported by default:
get head post put delete trace status headers request limp
Defines a route handler for METHOD to the given path:
get '/' => sub { 'Hello world!' };
Get or set the response status, and optionally reason.
status 404; status 401, 'Nope'; my $status = status; my ($status, $reason) = status;
Get or set the response headers.
headers Foo => 'bar', Fizz => 'buzz'; my @headers = headers; my $headers = headers;
Returns a HASH of the request. Request keys are: method, uri, and version. It may also contain headers which is an ARRAY, hheaders which is a HASH form of the headers, and body.
HASH
method
uri
version
headers
ARRAY
hheaders
body
There is no decoding of the body content nor URL paramters.
Starts the server. You can pass it the same options as IO::Socket::INET takes. The default options are:
Listen => 5, ReuseAddr => 1, LocalAddr => 'localhost', LocalPort => 8080, Proto => 'tcp'
This keyword should be called at the very end of the script, once all routes are defined. At this point, Dancer takes over control.
Copyright (C) 2014 by Ashley Willis <ashley@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.
IO::Socket::INET
To install Limper, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Limper
CPAN shell
perl -MCPAN -e shell install Limper
For more information on module installation, please visit the detailed CPAN module installation guide.