From: Dobrica Pavlinusic Date: Fri, 21 May 2010 14:09:44 +0000 (+0200) Subject: use before_dispatch plugin hook to audit requests X-Git-Url: http://git.rot13.org/?p=MojoFacets.git;a=commitdiff_plain;h=d4b6362ce5d4504c8e002e7c6861e714d0d68cf4 use before_dispatch plugin hook to audit requests --- diff --git a/lib/MojoFacets.pm b/lib/MojoFacets.pm index f353f33..dd80788 100644 --- a/lib/MojoFacets.pm +++ b/lib/MojoFacets.pm @@ -7,6 +7,8 @@ our $VERSION = '0.0001'; use base 'Mojolicious'; +use Data::Dump qw(dump); + # This method will run once at server start sub startup { my $self = shift; @@ -16,6 +18,19 @@ sub startup { # Default route $r->route('/:controller/:action/:id')->to('data#index', id => 1); + +# $self->plugin( 'request_timer' ); + + $self->plugins->add_hook( + before_dispatch => sub { + my ($self, $c) = @_; + my $tx = $c->tx; + # Do whatever you want with the transaction here + if ( $tx->req->url->query ) { + warn "# before_dispatch url ",dump($tx->req->url); + } + } + ); } 1;