From 02cd99a7f373afa92bf2ebdcebcd1b412979d950 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 5 Apr 2012 20:36:14 +0000 Subject: [PATCH 1/2] wording improvements --- lib/Plack/Middleware/Conditional.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Plack/Middleware/Conditional.pm b/lib/Plack/Middleware/Conditional.pm index 9f9ddcce6..532fb85cd 100644 --- a/lib/Plack/Middleware/Conditional.pm +++ b/lib/Plack/Middleware/Conditional.pm @@ -36,7 +36,7 @@ Plack::Middleware::Conditional - Conditional wrapper for Plack middleware $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/ }, @@ -46,7 +46,7 @@ Plack::Middleware::Conditional - Conditional wrapper for Plack middleware =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. @@ -72,8 +72,8 @@ the explanation and might not exist. }; Note that in the last example I should come first -because the conditional check runs in I 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 conditions, which is +from outer to inner: that is, from the top to the bottom in the Builder DSL code. =head1 AUTHOR From 569a4c3c45406157e7e724d4c276f6f71f63076a Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 5 Apr 2012 20:36:39 +0000 Subject: [PATCH 2/2] use the same example in the OO example, for easier comparison --- lib/Plack/Middleware/Conditional.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Plack/Middleware/Conditional.pm b/lib/Plack/Middleware/Conditional.pm index 532fb85cd..8ce789628 100644 --- a/lib/Plack/Middleware/Conditional.pm +++ b/lib/Plack/Middleware/Conditional.pm @@ -32,15 +32,15 @@ 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 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