MojoX::Dispatcher::Static - Serve Static Files
use MojoX::Dispatcher::Static; # New dispatcher my $dispatcher = MojoX::Dispatcher::Static->new( prefix => '/images', root => '/ftp/pub/images' ); # Dispatch my $success = $dispatcher->dispatch($c);
MojoX::Dispatcher::Static is a dispatcher for static files with RANGE and IF-MODIFIED-SINCE support.
RANGE
IF-MODIFIED-SINCE
MojoX::Dispatcher::Static implements the following attributes.
prefix
my $prefix = $dispatcher->prefix; $dispatcher = $dispatcher->prefix('/static');
Prefix path to remove from incoming paths before dispatching.
types
my $types = $dispatcher->types; $dispatcher = $dispatcher->types(MojoX::Types->new);
MIME types, by default a MojoX::Types object.
root
my $root = $dispatcher->root; $dispatcher = $dispatcher->root('/foo/bar/files');
Directory to serve static files from.
MojoX::Dispatcher::Static inherits all methods from Mojo::Base and implements the follwing the ones.
dispatch
my $success = $dispatcher->dispatch($c);
Dispatch a MojoX::Controller object.
serve
my $success = $dispatcher->serve($c, 'foo/bar.html');
Serve a specific file.
serve_404
my $success = $dispatcher->serve_404($c); my $success = $dispatcher->serve_404($c, '404.html');
Serve a 404 error page, guaranteed to render at least a default page.
404
serve_500
my $success = $dispatcher->serve_500($c); my $success = $dispatcher->serve_500($c, '500.html');
Serve a 500 error page, guaranteed to render at least a default page.
500
serve_error
my $success = $dispatcher->serve_error($c, 404); my $success = $dispatcher->serve_error($c, 404, '404.html');
Serve error page, guaranteed to render at least a default page.
Mojolicious, Mojolicious::Book, http://mojolicious.org.
To install Mojolicious, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious
CPAN shell
perl -MCPAN -e shell install Mojolicious
For more information on module installation, please visit the detailed CPAN module installation guide.