[Jifty-commit] r6838 - jifty/trunk/lib/Jifty/Plugin

Jifty commits jifty-commit at lists.jifty.org
Wed Apr 22 06:08:40 EDT 2009


Author: sartak
Date: Wed Apr 22 06:08:40 2009
New Revision: 6838

Modified:
   jifty/trunk/lib/Jifty/Plugin/RequestInspector.pm

Log:
url_filter option for the plugin

Modified: jifty/trunk/lib/Jifty/Plugin/RequestInspector.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/RequestInspector.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/RequestInspector.pm	Wed Apr 22 06:08:40 2009
@@ -4,6 +4,8 @@
 use base 'Jifty::Plugin';
 use Time::HiRes 'time';
 
+__PACKAGE__->mk_accessors(qw(url_filter));
+
 my $current_inspection;
 my @requests;
 
@@ -11,6 +13,10 @@
     my $self = shift;
     return if $self->_pre_init;
 
+    my %opt = @_;
+    my $filter = $opt{url_filter} || '.*';
+    $self->url_filter(qr/$filter/);
+
     Jifty::Handler->add_trigger(before_request => sub {
         $self->before_request(@_);
     });
@@ -88,7 +94,12 @@
 }
 
 sub should_handle_request {
-    return 1;
+    my $self = shift;
+    my $cgi  = shift;
+
+    my $url = $cgi->url(-absolute => 1, -path_info => 1);
+
+    return $url =~ $self->url_filter;
 }
 
 1;


More information about the Jifty-commit mailing list