|
NAMECatalyst::Plugin::AtomServer - Atom API server for Catalyst applications SYNOPSIS use Catalyst qw( AtomServer
Authentication
Authentication::Credential::Atom
Authentication::Store::Minimal
);
DESCRIPTIONCatalyst::Plugin::AtomServer implements the necessary bits to make it easy to build an Atom API server for any Catalyst-based application. It implements:
EXAMPLEBelow is an example server that implements authentication, dispatching, and views. package My::App;
use strict;
use Catalyst qw( AtomServer
Authentication
Authentication::Credential::Atom
Authentication::Store::Minimal
);
use My::App::View::XML;
use XML::Atom::Feed;
__PACKAGE__->config(
name => 'MyApp',
authentication => { users => { foo => { password => 'bar' } } },
);
__PACKAGE__->setup;
sub default : Private {
my($self, $c) = @_;
$c->request->is_atom(1);
my $method = $c->request->method;
if ($method eq 'GET') {
$c->forward('get_entries');
}
}
sub get_entries : Private {
my($self, $c) = @_;
## Authenticate the user using WSSE or Basic auth.
$c->login_atom or die "Unauthenticated";
my $feed = XML::Atom::Feed->new;
$feed->title('Blog');
$c->stash->{xml_atom_object} = $feed;
}
sub end : Private {
my($self, $c) = @_;
$c->forward('My::App::View::XML');
}
package My::App::View::XML;
use base qw( Catalyst::View::Atom::XML );
SEE ALSOXML::Atom, Catalyst AUTHORSix Apart, cpan@sixapart.com LICENSECatalyst::Plugin::AtomServer is free software; you may redistribute it and/or modify it under the same terms as Perl itself. AUTHOR & COPYRIGHTExcept where otherwise noted, Catalyst::Plugin::AtomServer is Copyright 2006 Six Apart, cpan@sixapart.com. All rights reserved.
|