PrePAN

Sign in to PrePAN

Plack::App::GzipStatic mimics gzip_static

Good

Synopsis

use Plack::App::GzipStatic;
my $app = Plack::App::GzipStatic->new({root => "/path/to/static"})->to_app;

# When PATH_INFO is "/bootstrap.css",
# returns 'bootstrap.css.gz'   if it exists and HTTP_ACCEPT_ENCODING has gzip.
# returns 'bootstrap.css'      if it exists.
# returns 'bootstrap.css.css'  if it exists. (For Apache MultiViews)
# 404                          otherwise.

builder {
   mount "/static" => $app;

   mount "/" => sub {
      ... # main app
   };
};

Description

This is a static file server (most codes are stolen from Plack::App::File) with additional feature gzip_static, known for nginx and Apache.

Comments

Please sign up to post a review.