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_with_id => { 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:
26 $base/id/[identifier]/delete
27 $base/id/[identifier]/update
29 Where $base is the URI described by L</setup>, the chain root of the controller.
31 =method_protected setup
37 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.
40 ( action => { setup => { PathPart => 'track', Chained => '/api/rpc/rpc_base' } },
46 sub index : Chained('setup') PathPart('') Args(0) {
47 my ( $self, $c ) = @_;
49 $self->push_error($c, { message => 'Not implemented' });
50 $c->res->status( '404' );
53 =method_protected create
55 Chained: L</objects_no_id>
59 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/update_or_create>.
63 sub create :Chained('objects_no_id') :PathPart('create') :Args(0)
66 $self->update_or_create($c);
69 =method_protected list
71 Chained: L</deserialize>
75 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/list>.
79 sub list :Chained('deserialize') :PathPart('list') :Args(0)
82 $self->next::method($c);
85 =method_protected item
87 Chained: L</object_with_id>
91 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/item>.
95 sub item :Chained('object_with_id') :PathPart('') :Args(0)
98 $self->next::method($c);
101 =method_protected update
103 Chained: L</object_with_id>
107 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/update_or_create>.
111 sub update :Chained('object_with_id') :PathPart('update') :Args(0)
114 $self->update_or_create($c);
117 =method_protected delete
119 Chained: L</object_with_id>
123 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/delete>.
127 sub delete :Chained('object_with_id') :PathPart('delete') :Args(0)
130 $self->next::method($c);
133 =method_protected update_bulk
135 Chained: L</objects_no_id>
139 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/update_or_create> for multiple objects.
143 sub update_bulk :Chained('objects_no_id') :PathPart('update') :Args(0)
146 $self->update_or_create($c);
149 =method_protected delete_bulk
151 Chained: L</objects_no_id>
155 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/delete> for multiple objects.
159 sub delete_bulk :Chained('objects_no_id') :PathPart('delete') :Args(0)
162 $self->next::method($c);