BUGFIX: abstract shouldn't die for registrations without work
[angular-drzb] / angular-server.pl
index 7b75c41..80d2392 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;
@@ -256,7 +272,7 @@ hook after_dispatch => sub {
        my $browser_etag = $self->req->headers->header('If-None-Match');
        return unless $browser_etag && $browser_etag eq $our_etag;
 
-       $self->app->log->info("HTTP cache hit ", dump( $self->req->url->to_string ), $our_etag );
+       $self->app->log->debug("HTTP cache hit " . $self->req->url->to_string . " $our_etag" );
 
        $self->res->code(304);
        $self->res->body('');