use Clone qw(clone);
use Mojo::UserAgent;
-our $VERSION = '0.3';
+our $VERSION = `git describe`;
+chomp $VERSION;
sub new_uuid { Time::HiRes::time * 100000 }
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 );
$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;
organizations => {
map => q| function(doc) {
if ( doc.user.organization != '' ) {
- emit(doc.user.organization, 1);
+ if ( doc.user.organization )
+ emit(doc.user.organization, 1);
if ( doc.user.persons ) {
doc.user.persons.forEach( function(person) {
- emit(person.organization, 1);
+ if ( person.organization )
+ emit(person.organization, 1);
});
}
}
return if $self->res->headers->header('ETag');
- my $our_etag = Mojo::ByteStream->new($body)->md5_sum;
+ my $our_etag = Mojo::ByteStream->new($body . $VERSION)->md5_sum;
$self->res->headers->header('ETag' => $our_etag);
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('');