Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

plack::middleware::conditional(3pm) [debian man page]

Plack::Middleware::Conditional(3pm)			User Contributed Perl Documentation		       Plack::Middleware::Conditional(3pm)

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(3pm)

Check Out this Related Man Page

Plack::Middleware::StackTrace(3pm)			User Contributed Perl Documentation			Plack::Middleware::StackTrace(3pm)

NAME
Plack::Middleware::StackTrace - Displays stack trace when your app dies SYNOPSIS
enable "StackTrace"; DESCRIPTION
This middleware catches exceptions (run-time errors) happening in your application and displays nice stack trace screen. The stack trace is also stored in the environment as a plaintext and HTML under the key "plack.stacktrace.text" and "plack.stacktrace.html" respectively, so that middleware futher up the stack can reference it. This middleware is enabled by default when you run plackup in the default development mode. You're recommended to use this middleware during the development and use Plack::Middleware::HTTPExceptions in the deployment mode as a replacement, so that all the exceptions thrown from your application still get caught and rendered as a 500 error response, rather than crashing the web server. Catching errors in streaming response is not supported. CONFIGURATION
force enable "StackTrace", force => 1; Force display the stack trace when an error occurs within your application and the response code from your application is 500. Defaults to off. The use case of this option is that when your framework catches all the exceptions in the main handler and returns all failures in your code as a normal 500 PSGI error response. In such cases, this middleware would never have a chance to display errors because it can't tell if it's an application error or just random "eval" in your code. This option enforces the middleware to display stack trace even if it's not the direct error thrown by the application. no_print_errors enable "StackTrace", no_print_errors => 1; Skips printing the text stacktrace to console ("psgi.errors"). Defaults to 0, which means the text version of the stack trace error is printed to the errors handle, which usually is a standard error. AUTHOR
Tokuhiro Matsuno Tatsuhiko Miyagawa SEE ALSO
Devel::StackTrace::AsHTML Plack::Middleware Plack::Middleware::HTTPExceptions perl v5.14.2 2011-07-08 Plack::Middleware::StackTrace(3pm)
Man Page