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
21 L<Catalyst::Controller::DBIC::API>.
23 By default provides the following endpoints:
28 $base/id/[identifier]/delete
29 $base/id/[identifier]/update
31 Where $base is the URI described by L</setup>, the chain root of the controller.
33 =method_protected setup
39 As described in L<Catalyst::Controller::DBIC::API/setup>, this action is the
40 chain root of the controller but has no pathpart or chain parent defined by
43 These must be defined in order for the controller to function.
45 The neatest way is normally to define these using the controller's config.
48 ( action => { setup => { PathPart => 'track', Chained => '/api/rpc/rpc_base' } },
54 =method_protected create
56 Chained: L</objects_no_id>
60 Provides an endpoint to the functionality described in
61 L<Catalyst::Controller::DBIC::API/update_or_create>.
65 sub create : Chained('objects_no_id') : PathPart('create') : Args(0) {
66 my ( $self, $c ) = @_;
67 $self->update_or_create($c);
70 =method_protected list
72 Chained: L</deserialize>
76 Provides an endpoint to the functionality described in
77 L<Catalyst::Controller::DBIC::API/list>.
81 sub list : Chained('deserialize') : PathPart('list') : Args(0) {
82 my ( $self, $c ) = @_;
83 $self->next::method($c);
86 =method_protected item
88 Chained: L</object_with_id>
92 Provides an endpoint to the functionality described in
93 L<Catalyst::Controller::DBIC::API/item>.
97 sub item : Chained('object_with_id') : PathPart('') : Args(0) {
98 my ( $self, $c ) = @_;
99 $self->next::method($c);
102 =method_protected update
104 Chained: L</object_with_id>
108 Provides an endpoint to the functionality described in
109 L<Catalyst::Controller::DBIC::API/update_or_create>.
113 sub update : Chained('object_with_id') : PathPart('update') : Args(0) {
114 my ( $self, $c ) = @_;
115 $self->update_or_create($c);
118 =method_protected delete
120 Chained: L</object_with_id>
124 Provides an endpoint to the functionality described in
125 L<Catalyst::Controller::DBIC::API/delete>.
129 sub delete : Chained('object_with_id') : PathPart('delete') : Args(0) {
130 my ( $self, $c ) = @_;
131 $self->next::method($c);
134 =method_protected update_bulk
136 Chained: L</objects_no_id>
140 Provides an endpoint to the functionality described in
141 L<Catalyst::Controller::DBIC::API/update_or_create> for multiple objects.
145 sub update_bulk : Chained('objects_no_id') : PathPart('update') : Args(0) {
146 my ( $self, $c ) = @_;
147 $self->update_or_create($c);
150 =method_protected delete_bulk
152 Chained: L</objects_no_id>
156 Provides an endpoint to the functionality described in
157 L<Catalyst::Controller::DBIC::API/delete> for multiple objects.
161 sub delete_bulk : Chained('objects_no_id') : PathPart('delete') : Args(0) {
162 my ( $self, $c ) = @_;