Limper::SendFile - add static content support to Limper
version 0.005
# order is important: use Limper::SendFile; use Limper; # some other routes get qr{^/} => sub { send_file; # sends request->{uri} by default }; limp;
Limper::SendFile extends Limper to also return actual files. Because sometimes that's needed.
The following are all additionally exported by default:
public send_file
Also exportable:
mime_types parse_date
Sends either the file name given, or the value of request->{uri} if no file name given.
request->{uri}
The following as the last defined route will have Limper look for the file as a last resort:
get qr{^/} => sub { send_file }
Content-Type will be set by file extension if known and header has not already been defined. Default is text/plain.
Get or set the public root directory. Default is ./public/.
my $public = public; public '/var/www/langlang.us/public_html';
Liberally parses whatever date a client might give, returning a Unix timestamp.
# these all return 784111777 my $date = parse_date("Sun, 06 Nov 1994 08:49:37 GMT"); my $date = parse_date("Sunday, 06-Nov-94 08:49:37 GMT"); my $date = parse_date("Sun Nov 6 08:49:37 1994");
Returns a HASH of file extension / content-type pairs.
An after hook is created to support If-Modified-Since and If-Unmodified-Since, comparing to Last-Modified. This runs for all defined routes, not just those using send_file.
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
Limper::Engine::PSGI
Limper::SendJSON
To install Limper::SendFile, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Limper::SendFile
CPAN shell
perl -MCPAN -e shell install Limper::SendFile
For more information on module installation, please visit the detailed CPAN module installation guide.