diff options
| author | franck cuny <franck@lumberjaph.net> | 2010-09-13 13:31:56 +0200 |
|---|---|---|
| committer | franck cuny <franck@lumberjaph.net> | 2010-09-13 13:31:56 +0200 |
| commit | 3e3dc478fc9b4eb90681df89156dfcc8f7f81481 (patch) | |
| tree | b9788b0d48f524bc4c0aeeb48c744a8f7b097910 /eg/couchdb.pl | |
| download | net-http-spore-3e3dc478fc9b4eb90681df89156dfcc8f7f81481.tar.gz | |
initial import
Diffstat (limited to 'eg/couchdb.pl')
| -rw-r--r-- | eg/couchdb.pl | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/eg/couchdb.pl b/eg/couchdb.pl new file mode 100644 index 0000000..737e76b --- /dev/null +++ b/eg/couchdb.pl @@ -0,0 +1,38 @@ +use strict; +use warnings; +use 5.010; +use YAML::Syck; +use Net::HTTP::Spore; +use Try::Tiny; + +my $api = Net::HTTP::Spore->new_from_spec(shift, api_base_url => 'http://localhost:5984'); + +$api->enable('Format::JSON'); +$api->enable('Runtime'); +$api->enable('UserAgent'); + +#my $documents = $api->get_all_documents(database => 'spore'); +#warn Dump $documents; +#say "status => ".$documents->[0]; +#say "body => ".Dump $documents->[2]; +#say "headers=> ".Dump $documents->[1]; + +my $res; + +#$res = $api->create_document_with_id(database => 'spore', doc_id => 1, payload => {foo => 'bar'}); +#warn Dump $res; + +#$res = $api->delete_document(database =>'spore', doc_id => 1, rev => $res->body->{rev}); +#warn Dump $res; + +$res = $api->create_document_without_id(database => 'spore', payload => {foo => 'baz', bar => 'foobaz'}); +warn Dump $res; + +#try { + #$res = $api->get_document( database => 'spore', doc_id => 1 ); +#} +#catch { + #warn Dump $_->[2]; + #warn Dump $_->[1]; +#}; + |
