Plack::Middleware::Static man page on Fedora

Man page or keyword search:  
man Server   31170 pages
apropos Keyword Search (all sections)
Output format
Fedora logo
[printable version]

Plack::Middleware::StaUser3Contributed Perl DocumePlack::Middleware::Static(3)

NAME
       Plack::Middleware::Static - serve static files with Plack

SYNOPSIS
	 use Plack::Builder;

	 builder {
	     enable "Plack::Middleware::Static",
		 path => qr{^/(images|js|css)/}, root => './htdocs/';
	     $app;
	 };

DESCRIPTION
       This middleware allows your Plack-based application to serve static
       files.

       Note that if you are building an app using Plack::App::URLMap, you
       should consider using Plack::App::File to serve static files instead.
       This makes the overall routing of your application simpler to
       understand.

       With this middleware, if a static file exists for the requested path,
       it will be served. If it does not exist, by default this middleware
       returns a 404, but you can set the "pass_through" option to change this
       behavior.

       If the requested document is not within the "root" or the file is there
       but not readable, this middleware will return a 403 Forbidden response.

       The content type returned will be determined from the file extension by
       using Plack::MIME.

CONFIGURATIONS
       path, root
	     enable "Plack::Middleware::Static",
		 path => qr{^/static/}, root => 'htdocs/';

	   The "path" option specifies the URL pattern (regular expression) or
	   a callback to match against requests. If the <path> option matches,
	   the middleware looks in "root" to find the static files to serve.
	   The default value of "root" is the current directory.

	   This example configuration serves "/static/foo.jpg" from
	   "htdocs/static/foo.jpg". Note that the matched portion of the path,
	   "/static/", still appears in the locally mapped path under "root".
	   If you don't want this to happen, you can use a callback to munge
	   the path as you match it:

	     enable "Plack::Middleware::Static",
		 path => sub { s!^/static/!! }, root => 'static-files/';

	   The callback should operate on $_ and return a true or false value.
	   Any changes it makes to $_ are used when looking for the static
	   file in the "root".

	   The configuration above serves "/static/foo.png" from
	   "static-files/foo.png", not "static-files/static/foo.png". The
	   callback specified in the "path" option matches against $_ munges
	   this value using "s///". The subsitution operator returns the
	   number of matches it made, so it will return true when the path
	   matches "^/static".

	   If you want to map multiple static directories from different
	   roots, simply add this middleware multiple times with different
	   configuration options.

       pass_through
	   When this option is set to a true value, then this middleware will
	   never return a 404 if it cannot find a matching file. Instead, it
	   will simply pass the request on to the application it is wrapping.

AUTHOR
       Tokuhiro Matsuno, Tatsuhiko Miyagawa

SEE ALSO
       Plack::Middleware Plack::Builder

perl v5.14.2			  2012-09-19	  Plack::Middleware::Static(3)
[top]

List of man pages available for Fedora

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net