X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FController%2FDBIC%2FAPI%2FREST.pm;h=a66cb8d7bea2b861042aec88fd62bc7495dce5a8;hb=3d85db11441182964cf35818ed25265eec1b74e2;hp=474f80def6286e35d18f75213f7f886b0c50c52a;hpb=73517f507669cada16503d144607e42c86b65f64;p=catagits%2FCatalyst-Controller-DBIC-API.git diff --git a/lib/Catalyst/Controller/DBIC/API/REST.pm b/lib/Catalyst/Controller/DBIC/API/REST.pm index 474f80d..a66cb8d 100644 --- a/lib/Catalyst/Controller/DBIC/API/REST.pm +++ b/lib/Catalyst/Controller/DBIC/API/REST.pm @@ -18,8 +18,8 @@ Provides a REST style API interface to the functionality described in L, the chain root of the controller, and the request type will determine the L method to forward. @@ -36,49 +36,84 @@ As described in L, this action is the cha ... ); -=method_protected base +=method_protected no_id -Chained: L +Chained: L PathPart: none CaptureArgs: 0 -Forwards to list level methods described in L as follows: +Calls list level methods described in L as follows: -DELETE: forwards to L then L -POST/PUT: forwards to L then L +DELETE: L +POST/PUT: L GET: forwards to L =cut -sub base : Chained('setup') PathPart('') ActionClass('REST') Args {} +sub no_id : Chained('objects_no_id') PathPart('') ActionClass('REST') :Args(0) {} -sub base_PUT { +sub no_id_PUT +{ my ( $self, $c ) = @_; - - $c->forward('object'); - return if $self->get_errors($c); - $c->forward('update_or_create'); + $self->update_or_create($c); } -sub base_POST { +sub no_id_POST +{ my ( $self, $c ) = @_; + $self->update_or_create($c); +} - $c->forward('object'); - return if $self->get_errors($c); - $c->forward('update_or_create'); +sub no_id_DELETE +{ + my ( $self, $c ) = @_; + $self->delete($c); } -sub base_DELETE { +sub no_id_GET +{ my ( $self, $c ) = @_; - $c->forward('object'); - return if $self->get_errors($c); - $c->forward('delete'); + $self->list($c); } -sub base_GET { +=method_protected with_id + +Chained: L +PathPart: none +CaptureArgs: 0 + +Forwards to list level methods described in L as follows: + +DELETE: L +POST/PUT: L +GET: forwards to L + +=cut + +sub with_id :Chained('object_with_id') :PathPart('') :ActionClass('REST') :Args(0) {} + +sub with_id_PUT +{ + my ( $self, $c ) = @_; + $self->update_or_create($c); +} + +sub with_id_POST +{ my ( $self, $c ) = @_; + $self->update_or_create($c); +} - $c->forward('list'); +sub with_id_DELETE +{ + my ( $self, $c ) = @_; + $self->delete($c); +} + +sub with_id_GET +{ + my ( $self, $c ) = @_; + $self->item($c); } 1;