Skip to content

Commit

Permalink
Merge pull request plack#279 from karenetheridge/topic/middleware_con…
Browse files Browse the repository at this point in the history
…ditional_docs

Documentation for Middleware::Conditional
  • Loading branch information
miyagawa committed Apr 5, 2012
2 parents b59c8b3 + 569a4c3 commit 84b4178
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/Plack/Middleware/Conditional.pm
Expand Up @@ -32,21 +32,21 @@ Plack::Middleware::Conditional - Conditional wrapper for Plack middleware
use Plack::Builder;
builder {
enable_if { $_[0]->{REMOTE_ADDR} eq '127.0.0.1' } 'StackTrace';
enable_if { $_[0]->{REMOTE_ADDR} eq '127.0.0.1' } 'StackTrace', force => 1;
$app;
};
# Or more raw version of it
# or using the OO interface:
$app = Plack::Middleware::Conditional->wrap(
$app,
condition => sub { my $env = shift; $env->{HTTP_USER_AGENT} =~ /WebKit/ },
builder => sub { Plack::Middleware::SuperAdminConsole->wrap($_[0], @args) },
condition => sub { $_[0]->{REMOTE_ADDR} eq '127.0.0.1' },
builder => sub { Plack::Middleware::StackTrace->wrap($_[0], force => 1) },
);
=head1 DESCRIPTION
Plack::Middleware::Conditional is a piece of meta-middleware, to run a
specific middleware component under the runtime condition. The goal of
specific middleware component under runtime conditions. The goal of
this middleware is to avoid baking runtime configuration options in
individual middleware components, and rather share them as another
middleware component.
Expand All @@ -72,8 +72,8 @@ the explanation and might not exist.
};
Note that in the last example I<MobileDetector> should come first
because the conditional check runs in I<pre-run> condition, which is
from outer to inner and that is from the top to the bottom in the
because the conditional check runs in I<pre-run> conditions, which is
from outer to inner: that is, from the top to the bottom in the
Builder DSL code.
=head1 AUTHOR
Expand Down

0 comments on commit 84b4178

Please sign in to comment.