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=a1c47e1effb2a6b3e51f08a00a8fb1ecc90faabb;hp=a4970523f9f3a95c01f0551746ff0ab0132de7ce;hb=8cf0b66a04e74b7bd5db0c8041575825ec8f73d2;hpb=d273984026646e5b57c052deef3fcb9121122060 diff --git a/lib/Catalyst/Controller/DBIC/API/REST.pm b/lib/Catalyst/Controller/DBIC/API/REST.pm index a497052..a1c47e1 100644 --- a/lib/Catalyst/Controller/DBIC/API/REST.pm +++ b/lib/Catalyst/Controller/DBIC/API/REST.pm @@ -50,39 +50,56 @@ 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'); +} - $c->forward('object'); - return if $self->get_errors($c); +sub with_id :Chained('object_with_id') :PathPart('') :ActionClass('REST') :CaptureArgs(0) {} + +sub with_id_PUT +{ + my ( $self, $c ) = @_; $c->forward('update_or_create'); } -sub base_DELETE { +sub with_id_POST +{ my ( $self, $c ) = @_; - $DB::single =1; - $c->forward('object'); - return if $self->get_errors($c); - $c->forward('delete'); + $c->forward('update_or_create'); } -sub base_GET { +sub with_id_DELETE +{ my ( $self, $c ) = @_; + $c->forward('delete'); +} - $c->forward('list'); +sub with_id_GET +{ + my ( $self, $c ) = @_; + $c->forward('item'); } 1;