Plack::Middleware::Conditional 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::ConUseroContributed Perl DPlack::Middleware::Conditional(3)

NAME
       Plack::Middleware::Conditional - Conditional wrapper for Plack
       middleware

SYNOPSIS
	 use Plack::Builder;

	 builder {
	     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 { $_[0]->{REMOTE_ADDR} eq '127.0.0.1' },
	     builder => sub { Plack::Middleware::StackTrace->wrap($_[0], force => 1) },
	 );

DESCRIPTION
       Plack::Middleware::Conditional is a piece of meta-middleware, to run a
       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.

EXAMPLES
       Note that some of the middleware component names are just made up for
       the explanation and might not exist.

	 # Minify JavaScript if the browser is Firefox
	 enable_if { $_[0]->{HTTP_USER_AGENT} =~ /Firefox/ } 'JavaScriptMinifier';

	 # Enable Stacktrace when being accessed from the local network
	 enable_if { $_[0]->{REMOTE_ADDR} =~ /^10\.0\.1\.*/ } 'StackTrace';

	 # Work with other conditional setter middleware:
	 # Transcode Jpeg on the fly for mobile clients
	 builder {
	     enable 'MobileDetector';
	     enable_if { $_[0]->{'plack.mobile_detected'} }
	       'TranscodeJpeg', max_size => 30_000;
	     $app;
	 };

       Note that in the last example MobileDetector should come first because
       the conditional check runs in pre-run conditions, which is from outer
       to inner: that is, from the top to the bottom in the Builder DSL code.

AUTHOR
       Tatsuhiko Miyagawa

       Steve Cook

SEE ALSO
       Plack::Builder

perl v5.14.2			  2012-04-14 Plack::Middleware::Conditional(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