118 |
$status = 501; |
$status = 501; |
119 |
} |
} |
120 |
|
|
|
} elsif ( $url =~ m{($regex_dbs)/$} ) { |
|
|
|
|
121 |
=head2 Database |
=head2 Database |
122 |
|
|
123 |
L<http://wiki.apache.org/couchdb/HTTP_database_API> except compaction |
L<http://wiki.apache.org/couchdb/HTTP_database_API> except compaction |
124 |
|
|
125 |
=cut |
=cut |
126 |
|
|
127 |
|
} elsif ( |
128 |
|
$url =~ m{($regex_dbs)/$} |
129 |
|
# DELETE doesn't have trailing slash |
130 |
|
|| $method eq 'DELETE' && $url =~ m{($regex_dbs)$} |
131 |
|
) { |
132 |
|
|
133 |
my $database = $1; |
my $database = $1; |
134 |
|
|
135 |
my $dir = "$path/$database"; |
my $dir = "$path/$database"; |
161 |
} |
} |
162 |
} |
} |
163 |
|
|
164 |
|
warn "## database $database $status ",dump( $json ); |
165 |
|
|
166 |
} elsif ( $url =~ m{($regex_dbs)/([^?]+)\??(.+)?$} ) { |
} elsif ( $url =~ m{($regex_dbs)/([^?]+)\??(.+)?$} ) { |
167 |
my ($database,$id,$args) = ($1,$2,$3); |
my ($database,$id,$args) = ($1,$2,$3); |
168 |
|
|
266 |
|
|
267 |
} elsif ( $method eq 'PUT' ) { |
} elsif ( $method eq 'PUT' ) { |
268 |
|
|
269 |
warn "## ",dump( $tx->req ); # if $debug; |
warn "## ",dump( $tx->req ) if $debug; |
270 |
|
|
271 |
my $data = $tx->req->content->file->slurp; |
my $data = $tx->req->content->file->slurp; |
272 |
|
|
273 |
|
my $db_path = "$path/$database"; |
274 |
|
make_path $db_path unless -e $db_path; |
275 |
|
|
276 |
Storable::store( from_json($data), $p ); |
Storable::store( from_json($data), $p ); |
277 |
my $rev = file_rev $p; |
my $rev = file_rev $p; |
278 |
warn "store $p $rev size ", -s $p, " bytes | $data\n"; |
warn "store $p $rev size ", -s $p, " bytes | $data\n"; |
313 |
$status = 501; |
$status = 501; |
314 |
} |
} |
315 |
|
|
316 |
warn "WARNING: arg left from $url = ",dump( $arg ),$/ if keys %$arg; |
if ( keys %$arg ) { |
317 |
|
warn "WARNING: arg left from $url = ",dump( $arg ),$/; |
318 |
|
$status = 501; |
319 |
|
} |
320 |
|
|
321 |
} |
} |
322 |
|
|