Catalyst-Controller-DBIC-API
view release on metacpan or search on metacpan
lib/Catalyst/Controller/DBIC/API.pm view on Meta::CPAN
{ cds => ['tracks'] },
],
ordered_by => ['age'],
search_exposes => ['age', 'nickname', { cds => ['title', 'year'] }],
data_root => 'list',
item_root => 'data',
use_json_boolean => 1,
return_object => 1,
);
# Provides the following functional endpoints:
# /api/rpc/artist/create
# /api/rpc/artist/list
# /api/rpc/artist/id/[id]/delete
# /api/rpc/artist/id/[id]/update
=head1 DESCRIPTION
Easily provide common API endpoints based on your L<DBIx::Class> schema classes.
Module provides both RPC and REST interfaces to base functionality.
Uses L<Catalyst::Action::Serialize> and L<Catalyst::Action::Deserialize> to
serialize response and/or deserialise request.
=head1 OVERVIEW
This document describes base functionlity such as list, create, delete, update
and the setting of config attributes. L<Catalyst::Controller::DBIC::API::RPC>
and L<Catalyst::Controller::DBIC::API::REST> describe details of provided
endpoints to those base methods.
You will need to create a controller for each schema class you require API
endpoints for. For example if your schema has Artist and Track, and you want to
provide a RESTful interface to these, you should create
MyApp::Controller::API::REST::Artist and MyApp::Controller::API::REST::Track
which both subclass L<Catalyst::Controller::DBIC::API::REST>.
Similarly if you wanted to provide an RPC style interface then subclass
L<Catalyst::Controller::DBIC::API::RPC>. You then configure these individually
as specified in L</CONFIGURATION>.
Also note that the test suite of this module has an example application used to
run tests against. It maybe helpful to look at that until a better tutorial is
written.
lib/Catalyst/Controller/DBIC/API.pm view on Meta::CPAN
return;
}
$self->next::method($c);
}
Generally it's better to have one controller for each DBIC source with the
config hardcoded, but in some cases this isn't possible.
Note that the Chained, CaptureArgs and PathPart are just standard Catalyst
configuration parameters and that then endpoint specified in Chained - in this
case '/api/rpc/rpc_base' - must actually exist elsewhere in your application.
See L<Catalyst::DispatchType::Chained> for more details.
Below are explanations for various configuration parameters. Please see
L<Catalyst::Controller::DBIC::API::StaticArguments> for more details.
=head3 class
Whatever you would pass to $c->model to get a resultset for this class.
MyAppDB::Track for example.
lib/Catalyst/Controller/DBIC/API/REST.pm view on Meta::CPAN
=head1 VERSION
version 2.009000
=head1 DESCRIPTION
Provides a REST style API interface to the functionality described in
L<Catalyst::Controller::DBIC::API>.
By default provides the following endpoints:
$base (operates on lists of objects and accepts GET, PUT, POST and DELETE)
$base/[identifier] (operates on a single object and accepts GET, PUT, POST and DELETE)
Where $base is the URI described by L</setup>, the chain root of the controller
and the request type will determine the L<Catalyst::Controller::DBIC::API>
method to forward.
=head1 PROTECTED_METHODS
lib/Catalyst/Controller/DBIC/API/RPC.pm view on Meta::CPAN
=head1 VERSION
version 2.009000
=head1 DESCRIPTION
Provides an RPC API interface to the functionality described in
L<Catalyst::Controller::DBIC::API>.
By default provides the following endpoints:
$base/create
$base/list
$base/id/[identifier]
$base/id/[identifier]/delete
$base/id/[identifier]/update
Where $base is the URI described by L</setup>, the chain root of the controller.
=head1 PROTECTED_METHODS
lib/Catalyst/Controller/DBIC/API/RPC.pm view on Meta::CPAN
( action => { setup => { PathPart => 'track', Chained => '/api/rpc/rpc_base' } },
...
);
=head2 create
Chained: L</objects_no_id>
PathPart: create
CaptureArgs: 0
Provides an endpoint to the functionality described in
L<Catalyst::Controller::DBIC::API/update_or_create>.
=head2 list
Chained: L</deserialize>
PathPart: list
CaptureArgs: 0
Provides an endpoint to the functionality described in
L<Catalyst::Controller::DBIC::API/list>.
=head2 item
Chained: L</object_with_id>
PathPart: ''
Args: 0
Provides an endpoint to the functionality described in
L<Catalyst::Controller::DBIC::API/item>.
=head2 update
Chained: L</object_with_id>
PathPart: update
Args: 0
Provides an endpoint to the functionality described in
L<Catalyst::Controller::DBIC::API/update_or_create>.
=head2 delete
Chained: L</object_with_id>
PathPart: delete
Args: 0
Provides an endpoint to the functionality described in
L<Catalyst::Controller::DBIC::API/delete>.
=head2 update_bulk
Chained: L</objects_no_id>
PathPart: update
Args: 0
Provides an endpoint to the functionality described in
L<Catalyst::Controller::DBIC::API/update_or_create> for multiple objects.
=head2 delete_bulk
Chained: L</objects_no_id>
PathPart: delete
Args: 0
Provides an endpoint to the functionality described in
L<Catalyst::Controller::DBIC::API/delete> for multiple objects.
=head1 AUTHORS
=over 4
=item *
Nicholas Perez <nperez@cpan.org>
( run in 0.772 second using v1.01-cache-2.11-cpan-b61123c0432 )