X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Controller-DBIC-API.git;a=blobdiff_plain;f=lib%2FCatalyst%2FController%2FDBIC%2FAPI%2FREST.pm;h=b40b5de566003490ec260dd070274863f52f2727;hp=740b3a99e23a2e636c255edf9cbc88536911b05a;hb=609916e5de6201b2e2212328153657194b41a730;hpb=617efaa8a88cddd04c6ae42c14c4a483c78a329d diff --git a/lib/Catalyst/Controller/DBIC/API/REST.pm b/lib/Catalyst/Controller/DBIC/API/REST.pm index 740b3a9..b40b5de 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,52 +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: -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 { - my ( $self, $c ) = @_; +sub no_id : Chained('object_no_id') PathPart('') ActionClass('REST') :CaptureArgs(0) {} +sub no_id_PUT +{ + my ( $self, $c ) = @_; + $c->forward('update_or_create'); } -sub base_PUT { +sub no_id_POST +{ my ( $self, $c ) = @_; - - $c->forward('object'); - return if $self->get_errors($c); $c->forward('update_or_create'); } -sub base_POST { +sub no_id_DELETE +{ + my ( $self, $c ) = @_; + $c->forward('delete'); +} + +sub no_id_GET +{ + my ( $self, $c ) = @_; + $c->forward('list'); +} + +=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') :CaptureArgs(0) {} + +sub with_id_PUT +{ my ( $self, $c ) = @_; + $c->forward('update_or_create'); +} - $c->forward('object'); - return if $self->get_errors($c); +sub with_id_POST +{ + my ( $self, $c ) = @_; $c->forward('update_or_create'); } -sub base_DELETE { +sub with_id_DELETE +{ my ( $self, $c ) = @_; - $c->forward('object'); - return if $self->get_errors($c); $c->forward('delete'); } -sub base_GET { +sub with_id_GET +{ my ( $self, $c ) = @_; - - $c->forward('list'); + $c->forward('item'); } 1;