The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mojolicious::Static - Serve Static Files

SYNOPSIS

    use Mojolicious::Static;

DESCRIPTION

Mojolicious::Static is a dispatcher for static files with Range and If-Modified-Since support.

ATTRIBUTES

Mojolicious::Static implements the following attributes.

default_static_class

    my $class = $static->default_static_class;
    $static   = $static->default_static_class('main');

The dispatcher will use this class to look for files in the DATA section.

prefix

    my $prefix = $static->prefix;
    $static    = $static->prefix('/static');

Prefix path to remove from incoming paths before dispatching.

root

    my $root = $static->root;
    $static  = $static->root('/foo/bar/files');

Directory to serve static files from.

METHODS

Mojolicious::Static inherits all methods from Mojo::Base and implements the following ones.

dispatch

    my $success = $static->dispatch($c);

Dispatch a Mojolicious::Controller object.

serve

    my $success = $static->serve($c, 'foo/bar.html');

Serve a specific file.

serve_404

    my $success = $static->serve_404($c);
    my $success = $static->serve_404($c, '404.html');

Serve a 404 error page, guaranteed to render at least a default page.

serve_500

    my $success = $static->serve_500($c);
    my $success = $static->serve_500($c, '500.html');

Serve a 500 error page, guaranteed to render at least a default page.

serve_error

    my $success = $static->serve_error($c, 404);
    my $success = $static->serve_error($c, 404, '404.html');

Serve error page, guaranteed to render at least a default page.

SEE ALSO

Mojolicious, Mojolicious::Guides, http://mojolicious.org.