projects
/
angular-mojolicious.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of github.com:dpavlin/angular-mojolicious
[angular-mojolicious.git]
/
angular-server.pl
diff --git
a/angular-server.pl
b/angular-server.pl
index
4471a06
..
1f253a3
100755
(executable)
--- a/
angular-server.pl
+++ b/
angular-server.pl
@@
-23,15
+23,23
@@
sub _couchdb_put {
my $json = Mojo::JSON->new->encode( $data );
my $json = Mojo::JSON->new->encode( $data );
+ my $rev;
+
warn "# _couchdb_put $url = $json";
$client->put( "$couchdb/$url" => $json => sub {
my ($client,$tx) = @_;
warn "# _couchdb_put $url = $json";
$client->put( "$couchdb/$url" => $json => sub {
my ($client,$tx) = @_;
+ my ($message, $code) = $tx->error;
+ my $response = $tx->res->json;
+ warn "## response $code ",dump($response);
if ($tx->error) {
if ($tx->error) {
- die "ERROR
CouchDB ",$tx->error
;
+ die "ERROR
$code $message"
;
}
}
- my $response = $tx->res->json;
-
warn "## CouchDB response ",dump($response)
;
+ return
+
$rev = $response->{rev}
;
})->process;
})->process;
+
+ warn "## rev = $rev";
+ return $rev;
}
sub _couchdb_get {
}
sub _couchdb_get {
@@
-160,7
+168,8
@@
any [ 'post' ] => '/data/:database/:entity' => sub {
$json->{'$id'} ||= $id; # make sure $id is in there
$json->{'$id'} ||= $id; # make sure $id is in there
- _couchdb_put "/$database/$entity.$id" => $json;
+ my $rev = _couchdb_put "/$database/$entity.$id" => $json;
+ $json->{_rev} = $rev;
_render_jsonp( $self, $json );
};
_render_jsonp( $self, $json );
};