1 package Catalyst::Controller::DBIC::API::RPC;
2 #ABSTRACT: Provides an RPC interface to DBIx::Class
5 BEGIN { extends 'Catalyst::Controller::DBIC::API'; }
8 'action' => { object => { PathPart => 'id' } },
9 'default' => 'application/json',
10 'stash_key' => 'response',
12 'application/x-www-form-urlencoded' => 'JSON',
13 'application/json' => 'JSON',
19 Provides an RPC API interface to the functionality described in L<Catalyst::Controller::DBIC::API>.
21 By default provides the following endpoints:
25 $base/id/[identifier]/delete
26 $base/id/[identifier]/update
28 Where $base is the URI described by L</setup>, the chain root of the controller.
30 =method_protected setup
36 As described in L<Catalyst::Controller::DBIC::API/setup>, this action is the chain root of the controller but has no pathpart or chain parent defined by default, so these must be defined in order for the controller to function. The neatest way is normally to define these using the controller's config.
39 ( action => { setup => { PathPart => 'track', Chained => '/api/rpc/rpc_base' } },
43 =method_protected object
49 Provides an chain point to the functionality described in L<Catalyst::Controller::DBIC::API/object>. All object level endpoints should use this as their chain root.
53 sub index : Chained('setup') PathPart('') Args(0) {
54 my ( $self, $c ) = @_;
56 $self->push_error($c, { message => 'Not implemented' });
57 $c->res->status( '404' );
60 =method_protected create
66 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/update_or_create>.
70 sub create :Chained('setup') :PathPart('create') :Args(0)
73 $c->forward('object');
74 return if $self->get_errors($c);
75 $c->forward('update_or_create');
78 =method_protected list
84 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/list>.
88 sub list :Chained('setup') :PathPart('list') :Args(0) {
91 $self->next::method($c);
94 =method_protected update
100 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/update_or_create>.
104 sub update :Chained('object') :PathPart('update') :Args(0) {
107 $c->forward('update_or_create');
110 =method_protected delete
116 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/delete>.
120 sub delete :Chained('object') :PathPart('delete') :Args(0) {
123 $self->next::method($c);