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;

  my $static = Mojolicious::Static->new;

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

Class to use for finding files in DATA section, defaults to main.

paths

  my $paths = $static->paths;
  $static   = $static->paths(['/foo/bar/public']);

Directories to serve static files from.

  # Add another "public" directory
  push @{$static->paths}, '/foo/bar/public';

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, relative to paths.

SEE ALSO

Mojolicious, Mojolicious::Guides, http://mojolicio.us.