added x_audit
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 14 Jan 2013 23:40:59 +0000 (00:40 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 14 Jan 2013 23:40:59 +0000 (00:40 +0100)
angular-server.pl

index 7b75c41..cb998ad 100755 (executable)
@@ -69,6 +69,16 @@ helper locale => sub {
        return $locale{ $lang } || "MISSING $lang $_[1]";
 };
 
+helper ip => sub {
+       my $self = shift;
+       return
+               $self->req->headers->header('X-Forwarded-For')
+               || $self->req->headers->header('X-Real-IP')
+               || $self->tx->{remote_address}
+       ;
+};
+
+
 get '/js/services.js' => sub {
        my $self = shift;
        $self->stash( VERSION => $VERSION );
@@ -175,6 +185,12 @@ any [ 'post' ] => '/data/:database/:entity' => sub {
                $json->{entity} = $entity;
                warn "NEW $id\n";
        }
+
+       $json->{x_audit} = {
+               t  => Time::HiRes::time,
+               ip => $self->ip(),
+       };
+
        warn "## $database $entity $id body ",dump($self->req->body, $json);
 
        my $new = _couchdb_put "/$database/$entity.$id" => $json;