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 =method_protected index
52 Returns http status code 404 by default.
56 sub index : Chained('setup') PathPart('') Args(0) {
57 my ( $self, $c ) = @_;
59 $self->push_error($c, { message => 'Not implemented' });
60 $c->res->status( '404' );
63 =method_protected create
65 Chained: L</objects_no_id>
69 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/update_or_create>.
73 sub create :Chained('objects_no_id') :PathPart('create') :Args(0)
76 $self->update_or_create($c);
79 =method_protected list
81 Chained: L</deserialize>
85 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/list>.
89 sub list :Chained('deserialize') :PathPart('list') :Args(0)
92 $self->next::method($c);
95 =method_protected item
97 Chained: L</object_with_id>
101 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/item>.
105 sub item :Chained('object_with_id') :PathPart('') :Args(0)
108 $self->next::method($c);
111 =method_protected update
113 Chained: L</object_with_id>
117 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/update_or_create>.
121 sub update :Chained('object_with_id') :PathPart('update') :Args(0)
124 $self->update_or_create($c);
127 =method_protected delete
129 Chained: L</object_with_id>
133 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/delete>.
137 sub delete :Chained('object_with_id') :PathPart('delete') :Args(0)
140 $self->next::method($c);
143 =method_protected update_bulk
145 Chained: L</objects_no_id>
149 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/update_or_create> for multiple objects.
153 sub update_bulk :Chained('objects_no_id') :PathPart('update') :Args(0)
156 $self->update_or_create($c);
159 =method_protected delete_bulk
161 Chained: L</objects_no_id>
165 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/delete> for multiple objects.
169 sub delete_bulk :Chained('objects_no_id') :PathPart('delete') :Args(0)