NAME
Limper - extremely lightweight but not very powerful web application framework
VERSION
version 0.004
SYNOPSIS
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;
DESCRIPTION
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 (except for the tests, which only run if Net::HTTP::Client
is installed), 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. There is also no PSGI support or other similar fanciness.
It also fatpacks beautifully (at least on 5.10.1):
fatpack pack example.pl > example-packed.pl
EXPORTS
The following are all exported by default:
get post put del trace
status headers request limp
FUNCTIONS
get
post
put
del
trace
Defines a route handler for METHOD to the given path:
get '/' => sub { 'Hello world!' };
Note that a route to match HEAD requests is automatically created as well for get
.
status
Get or set the response status, and optionally reason.
status 404;
status 401, 'Nope';
my $status = status;
my ($status, $reason) = status;
headers
Get or set the response headers.
headers Foo => 'bar', Fizz => 'buzz';
my @headers = headers;
my $headers = headers;
request
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
.
There is no decoding of the body content nor URL paramters.
limp
Starts the server. You can pass it the same options as IO::Socket::INET takes. The default options are:
Listen => SOMAXCONN, ReuseAddr => 1, LocalAddr => 'localhost', LocalPort => 8080, Proto => 'tcp'
In addition, the first argument can be a HASH
to pass other settings:
limp({timeout => 60, workers => 10}, LocalAddr => '0.0.0.0', LocalPort => 3001);
Default timeout is 5
(seconds), and default workers is 10
. A timeout of 0
means never timeout.
This keyword should be called at the very end of the script, once all routes are defined. At this point, Limper takes over control.
COPYRIGHT AND LICENSE
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.