Security Advisories (3)
CPANSA-Plack-2015-0202 (2015-02-02)

Fixed a possible directory traversal with Plack::App::File on Win32.

CPANSA-Plack-2014-0801 (2014-08-01)

Plack::App::File would previously strip trailing slashes off provided paths. This in combination with the common pattern of serving files with Plack::Middleware::Static could allow an attacker to bypass a whitelist of generated files

CPANSA-Plack-2013-0131 (2013-01-31)

Fixed directory traversal bug in Plack::App::File on win32 environments

NAME

Plack::Middleware - Base class for easy-to-use PSGI middleware

SYNOPSIS

package Plack::Middleware::Foo;
use parent qw( Plack::Middleware );

sub call {
    my($self, $env) = @_;
    # Do something with $env

    # $self->app is the original app
    my $res = $self->app->($env);

    # Do something with $res
    return $res;
}

# then in app.psgi
use Plack::Builder;

my $app = sub { ... } # as usual

builder {
    enable "Plack::Middleware::Foo";
    enable "Plack::Middleware::Bar", %options;
    $app;
};

DESCRIPTION

Plack::Middleware is an utility base class to write PSGI middleware. All you have to do is to inherit from Plack::Middleware and then implement the callback call method (or to_app method that would return the PSGI code reference) to do the actual work. You can use $self->app to call the original (wrapped) application.

See Plack::Builder how to actually enable middlewares in your .psgi application file using the DSL. If you do not like our builder DSL, you can also use wrap method to wrap your application with a middleware:

use Plack::Middleware::Foo;

my $app = sub { ... };
$app = Plack::Middleware::Foo->wrap($app, %options);
$app = Plack::Middleware::Bar->wrap($app, %options);

SEE ALSO

Plack Plack::Builder