package AnyEvent::CouchDB;
use strict;
use warnings;
our $VERSION = '1.30';
use JSON;
use AnyEvent::HTTP;
use AnyEvent::CouchDB::Database;
use AnyEvent::CouchDB::Exceptions;
use URI;
use URI::Escape
"AnyEvent::CouchDB::Exception::HTTPError";
our $JSONError = "AnyEvent::CouchDB::Exception::JSONError";
# default JSON encoder
our $default_json = JSON->new->utf8;
# arbitrary uri support
sub _build
}
elsif ( !exists $headers->{'Content-Type'} ) {
$headers->{'Content-Type'} = 'application/json';
}
if ( exists $self->{http_auth} ) {
$headers->{'Authorization'} = $self->{http_auth};
ders', 'body' ],
},
'AnyEvent::CouchDB::Exception::JSONError' => {
isa => 'AnyEvent::CouchDB::Exception',
description => 'JSON decoding error',
},
'AnyEvent::CouchDB::Exception
# handle an HTTP error
}
when (ref eq 'AnyEvent::CouchDB::Exception::JSONError') {
# handle a JSON decoding error
}
default {
$_->show_trace(1);
warn "$_";
chDB::Exception for HTTP errors
=item AnyEvent::CouchDB::Exception::JSONError
A subclass of AnyEvent::CouchDB::Exception for JSON decoding errors
=back
=head1 API
This module provides the follow
t::CouchDB::Stream;
use strict;
use warnings;
use URI;
use AnyEvent::HTTP;
use Scalar::Util;
use JSON;
use Try::Tiny;
use MIME::Base64;
our $VERSION = '0.02';
sub new {
my $class = shift
sub { };
my $headers = delete $args{headers}
|| { 'Content-Type' => 'application/json' };
my $include_docs = delete $args{include_docs};
my $uri = URI->new($server);
$uri
e, $json ) = @_;
$set_timeout->();
if ($json) {
try {
$on_change->(JSON::decode_json($json));
';
use JSON;
use AnyEvent::HTTP;
use AnyEvent::CouchDB::Exceptions;
use Data::Dump::Streamer;
use URI::Escape qw( uri_escape uri_escape_utf8 );
use IO::All;
use MIME::Base64;
our $default_json;
# ma
:cvcb;
*default_json = *AnyEvent::CouchDB::default_json;
*_build_headers = *AnyEvent::CouchDB::_build_headers;
our $query = sub {
my $options = shift;
my $json = $default_json;
my @buf;
$name eq 'startkey' || $name eq 'endkey') {
$value = ref($value)
? uri_escape($json->encode($value))
: (defined $value)
? uri_escape_utf8(qq{"$value"})