6 our $VERSION = '0.0001';
8 use base 'Mojolicious';
10 use Data::Dump qw(dump);
12 use Time::HiRes qw(time);
17 warn "# before_dispatch req ",dump($tx->req->url, $tx->req->params);
18 my $parts = $tx->req->url->path->parts;
19 warn "## parts ",dump( $parts );
20 if ( $parts->[0] eq 'data' ) {
22 my $path = '/tmp/changes/';
23 mkdir $path unless -e $path;
24 $path .= sprintf '%.4f.%s', time(), join('.', @$parts);
25 store $tx->req->params, $path;
26 # $self->log->info( "$path ", -s $path, " bytes\n" );
27 warn "$path ", -s $path, " bytes\n";
33 # This method will run once at server start
38 my $r = $self->routes;
41 $r->route('/:controller/:action/:id')->to('data#index', id => 1);
43 # $self->plugin( 'request_timer' );
45 $self->plugins->add_hook(
46 before_dispatch => sub {
49 save_tx( $self, $tx );