MVC::Neaf::X::Files - serve static content for Not Even A Framework.
use MVC::Neaf qw(:sugar); neaf static "/path/in/url" => "/local/path", %options;
These options would go to this module's new() method described below.
Serving static content in production via a perl application framework is a bad idea. However, forcing the user to run a separate web-server just to test their CSS, JS, and images is an even worse one.
So this module is here to fill the gap.
%options may include:
buffer - buffer size for serving files. Currently this is also the size below which in-memory caching is on, but this MAY change in the future.
cache_ttl - if given, files below the buffer size will be stored in memory for cache_ttl seconds. EXPERIMENTAL. Cache API is not yet established.
Create a Neaf-compatible response using given path. The response is like follows:
{ -content => (file content), -headers => (length, name etc), -type => (content-type), -continue => (serve the rest of the file, if needed), };
Will die 404; if file is not there.
die 404;
This MAY be used to create more fine-grained control over static files.
EXPERIMENTAL. New options MAY be added.
Create a directory index reply. Used by serve_file() if dir_index given.
As of current, indices are not cached.
Returns list of arguments suitable for neaf->route(...);
Returns a Neaf-compatible hander sub.
DEPRECATED Use make_route instead.
To install MVC::Neaf, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MVC::Neaf
CPAN shell
perl -MCPAN -e shell install MVC::Neaf
For more information on module installation, please visit the detailed CPAN module installation guide.