From d4b6362ce5d4504c8e002e7c6861e714d0d68cf4 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Fri, 21 May 2010 16:09:44 +0200 Subject: [PATCH] use before_dispatch plugin hook to audit requests --- lib/MojoFacets.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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; -- 2.20.1