++ed by:

1 non-PAUSE user.

Ashley Willis

NAME

Limper::SendFile - add static content support to Limper

VERSION

version 0.005

SYNOPSIS

  # order is important:
  use Limper::SendFile;
  use Limper;

  # some other routes

  get qr{^/} => sub {
      send_file;        # sends request->{uri} by default
  };

  limp;

DESCRIPTION

Limper::SendFile extends Limper to also return actual files. Because sometimes that's needed.

EXPORTS

The following are all additionally exported by default:

  public send_file

Also exportable:

  mime_types parse_date

FUNCTIONS

send_file

Sends either the file name given, or the value of request->{uri} if no file name given.

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.

public

Get or set the public root directory. Default is ./public/.

  my $public = public;

  public '/var/www/langlang.us/public_html';

ADDITIONAL FUNCTIONS

parse_date

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");

mime_types

Returns a HASH of file extension / content-type pairs.

HOOKS

after

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 AND LICENSE

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.

SEE ALSO

Limper

Limper::Engine::PSGI

Limper::SendJSON