AtomBus
view release on metacpan or search on metacpan
Revision history for AtomBus
1.0405 2012-04-17
Fixed tests to set config options at compile time before AtomBus module
is loaded.
Removed unnecessary before hook. Initializing now happens when AtomBus
is loaded.
Fixed the structure of the config options in config.yml.
1.0404 2010-12-29
Making configuration more friendly. All AtomBus specific settings
should now be under the 'atombus' config setting.
1.0403 2010-12-29
Renaming AtomMQ to AtomBus.
1.0402 2010-12-29
The example config in the POD was incorrectly setting password instead
of pass.
lib/AtomBus.pm view on Meta::CPAN
our $VERSION = '1.0405'; # VERSION
set content_type => 'application/xml';
config->{plugins}{DBIC}{atombus} = config->{atombus}{db};
config->{plugins}{DBIC}{atombus}{schema_class} = 'AtomBus::Schema';
eval { schema->deploy }; # Fails gracefully if tables already exist.
get '/feeds/:feed_title/entries/:entry_id' => sub {
my $entry_id = 'urn:uuid:' . params->{entry_id};
my $db_entry = schema->resultset('AtomBusEntry')->find({id => $entry_id});
return send_error("No such message exists", 404)
unless $db_entry;
my $if_none_match = request->header('If-None-Match');
#TODO: support revised entries (i.e. Atompub PUT)
# my $revision_id = $db_entry->revision_id || $db_entry->id;
my $revision_id = $db_entry->id;
# If ETag matches current revision id of entry
if (my $id = $if_none_match) {
$id =~ s/^"(.*)"$/$1/; # Remove surrounding quotes
if ($revision_id eq $id) {
lib/AtomBus.pm view on Meta::CPAN
}
if (my $id = $start_after || $start_at) {
my $entry = schema->resultset('AtomBusEntry')->find({id => $id});
return send_error("No such message exists with id $id", 400)
unless $entry;
$order_id = $entry->order_id;
}
my $db_feed = schema->resultset('AtomBusFeed')->find(
{ title => $feed_title });
return send_error("No such feed exists named $feed_title", 404)
unless $db_feed;
my $feed = XML::Atom::Feed->new;
$feed->title($feed_title);
$feed->id($db_feed->id);
my $person = XML::Atom::Person->new;
$person->name($db_feed->author_name);
$feed->author($person);
$feed->updated($db_feed->updated);
t/01-basic.t view on Meta::CPAN
<div xmlns="http://www.w3.org/1999/xhtml">content111</div>
</content>
</entry>
};
(my $xml2 = $xml1) =~ s/111/222/g;
my $feed = 'foo';
# Confirm that feed doesn't exist yet.
capture { # Silence output from schema->deploy in before filter.
response_status_is [ GET => "/feeds/$feed" ], 404;
};
my $res = dancer_response POST => "/feeds/$feed", { body => $xml1 };
is $res->{status} => 201, 'Got 201 for posting entry1.';
is schema->resultset('AtomBusEntry')->count() => 1, '1 entries in db.';
is schema->resultset('AtomBusFeed')->count() => 1, '1 feed in db.';
my ($entry1) = schema->resultset('AtomBusEntry')->search(
{ title => 'title111', content => 'content111', feed_title => $feed });
t/02-paging.t view on Meta::CPAN
<entry>
<title>title%s</title>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">content%s</div>
</content>
</entry>
};
# Confirm that feed doesn't exist yet.
capture { # Silence output from schema->deploy in before filter.
response_status_is [ GET => "/feeds/foo" ], 404;
};
# Create one entry and examine result.
my $res = dancer_response POST => "/feeds/foo", { body => sprintf($xml, 1, 1) };
is $res->{status}=> 201, 'Status was 201';
my $etag = new URI($res->{headers}->{etag}, 'urn');
my $location = new URI($res->{headers}->{location}, 'http');
my $id_nss = $location;
($id_nss) =~ s,^.*/,,;
is $location->path => "/feeds/foo/entries/$id_nss", 'Location header is well-structured.';
( run in 0.697 second using v1.01-cache-2.11-cpan-39bf76dae61 )