Catmandu::FedoraCommons::Response3pm
Perl model for generic fedora commons rest api responses
Usage
use Catmandu::FedoraCommons;my $fedora = Catmandu::FedoraCommons->new('http://localhost:8080/fedora','fedoraAdmin','fedoraAdmin');my $result = $fedora->findObjects(terms=>'*');die $resut->error unless $result->is_ok;my $obj = $result->parse_content;$result->is_ok;$result->error;$result->raw;$result->content_type;$result->length;$result->date;$result->parse_content();$result->parse_content($my_model);
Overview
A Catmandu::FedoraCommons::Response gets returned for every Catmandu::FedoraCommons method. This response contains the raw HTTP content of a Fedora Commons request and can also be used to parse XML responses into Perl objects using the parse_content function. For more information on the Perl objects see the information in the Catmandu::FedoraCommons::Model packages.
Methods
is_ok()
Returns true when the result Fedora Commons response contains no errors.
error()
Returns the error message of the Fedora Commons response if available.
parse_content($model)
Returns a Perl representation of the Fedora Commons response. Optionally a model object can be provided that implements a $obj->parse($bytes) method and returns a Perl object. If no model is provided then default models from the Catmandu::FedoraCommons::Model namespace are used.
Example:package MyParser;sub new {my $class = shift;return bless {} , $class;}sub parse {my ($self,$bytes) = @_;...return $perl}package main;my $fedora = Catmandu::FedoraCommons->new('http://localhost:8080/fedora','fedoraAdmin','fedoraAdmin');my $result = $fedora->findObjects(terms=>'*');my $perl = $result->parse_content(MyParser->new);
raw()
Returns the raw Fedora Commons response as a string.
content_type()
Returns the Content-Type of the Fedora Commons response.
length()
Returns the byte length of the Fedora Commons response.
date()
Returns the date of the Fedora Commons response.
Releases
Unchanged in 2 releases since Debian 12 (Bookworm).