1 package Catalyst::Controller::DBIC::API::RPC;
3 #ABSTRACT: Provides an RPC interface to DBIx::Class
6 BEGIN { extends 'Catalyst::Controller::DBIC::API'; }
9 'action' => { object_with_id => { PathPart => 'id' } },
10 'default' => 'application/json',
11 'stash_key' => 'response',
13 'application/x-www-form-urlencoded' => 'JSON',
14 'application/json' => 'JSON',
20 Provides an RPC API interface to the functionality described in L<Catalyst::Controller::DBIC::API>.
22 By default provides the following endpoints:
27 $base/id/[identifier]/delete
28 $base/id/[identifier]/update
30 Where $base is the URI described by L</setup>, the chain root of the controller.
32 =method_protected setup
38 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.
41 ( action => { setup => { PathPart => 'track', Chained => '/api/rpc/rpc_base' } },
47 =method_protected create
49 Chained: L</objects_no_id>
53 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/update_or_create>.
57 sub create : Chained('objects_no_id') : PathPart('create') : Args(0) {
58 my ( $self, $c ) = @_;
59 $self->update_or_create($c);
62 =method_protected list
64 Chained: L</deserialize>
68 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/list>.
72 sub list : Chained('deserialize') : PathPart('list') : Args(0) {
73 my ( $self, $c ) = @_;
74 $self->next::method($c);
77 =method_protected item
79 Chained: L</object_with_id>
83 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/item>.
87 sub item : Chained('object_with_id') : PathPart('') : Args(0) {
88 my ( $self, $c ) = @_;
89 $self->next::method($c);
92 =method_protected update
94 Chained: L</object_with_id>
98 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/update_or_create>.
102 sub update : Chained('object_with_id') : PathPart('update') : Args(0) {
103 my ( $self, $c ) = @_;
104 $self->update_or_create($c);
107 =method_protected delete
109 Chained: L</object_with_id>
113 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/delete>.
117 sub delete : Chained('object_with_id') : PathPart('delete') : Args(0) {
118 my ( $self, $c ) = @_;
119 $self->next::method($c);
122 =method_protected update_bulk
124 Chained: L</objects_no_id>
128 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/update_or_create> for multiple objects.
132 sub update_bulk : Chained('objects_no_id') : PathPart('update') : Args(0) {
133 my ( $self, $c ) = @_;
134 $self->update_or_create($c);
137 =method_protected delete_bulk
139 Chained: L</objects_no_id>
143 Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/delete> for multiple objects.
147 sub delete_bulk : Chained('objects_no_id') : PathPart('delete') : Args(0) {
148 my ( $self, $c ) = @_;