X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAction%2FREST.pm;h=87ba05f35bdf5144fda701cdfdf3e03f7110ceb1;hb=4ee2437628b1e4fce9569967577eb356ae12ea01;hp=4404b1c3ca07753e3bd6e4b765f0d99541710be8;hpb=e34b463b019471c7e6bde7c89dde8747baddfd1d;p=catagits%2FCatalyst-Action-REST.git diff --git a/lib/Catalyst/Action/REST.pm b/lib/Catalyst/Action/REST.pm index 4404b1c..87ba05f 100644 --- a/lib/Catalyst/Action/REST.pm +++ b/lib/Catalyst/Action/REST.pm @@ -17,7 +17,8 @@ use Catalyst::Controller::REST; BEGIN { require 5.008001; } -our $VERSION = '0.74'; +our $VERSION = '0.76'; +$VERSION = eval $VERSION; sub new { my $class = shift; @@ -40,15 +41,18 @@ Catalyst::Action::REST - Automated REST Method Dispatching ... do something for GET requests ... } - sub foo_PUT { - ... do somethign for PUT requests ... + # alternatively use an Action + sub foo_PUT : Private { + ... do something for PUT requests ... } =head1 DESCRIPTION This Action handles doing automatic method dispatching for REST requests. It takes a normal Catalyst action, and changes the dispatch to append an -underscore and method name. +underscore and method name. First it will try dispatching to an action with +the generated name, and failing that it will try to dispatch to a regular +method. For example, in the synopsis above, calling GET on "/foo" would result in the foo_GET method being dispatched. @@ -94,7 +98,10 @@ sub dispatch { my ($code, $name); # Common case, for foo_GET etc - if ($code = $controller->can($rest_method)) { + if ( $code = $controller->action_for($rest_method) ) { + $c->execute( $self->class, $self, @{ $c->req->args } ); + return $c->forward( $code, $c->req->args ); + } elsif ($code = $controller->can($rest_method)) { # Exceute normal action $c->execute( $self->class, $self, @{ $c->req->args } ); $name = $rest_method; @@ -184,12 +191,10 @@ for this to run smoothly. =back -=head1 MAINTAINER - -Hans Dieter Pearcey - =head1 CONTRIBUTORS +Arthur Axel "fREW" Schmidt + Christopher Laco Luke Saunders @@ -200,6 +205,8 @@ Daisuke Maki J. Shirley +Hans Dieter Pearcey + Tomas Doran (t0m) =head1 AUTHOR