X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAction%2FREST.pm;h=d27be7ddccc4b03625787e674d803503f6833032;hb=d3f3a2ed11595db3f5d10e8ae395a04209670356;hp=edef056d9a72e020cdbe7dd8d9cb4932f4d183c4;hpb=102106be3c8e89bbc54717a51ce02b6e778f4698;p=catagits%2FCatalyst-Action-REST.git diff --git a/lib/Catalyst/Action/REST.pm b/lib/Catalyst/Action/REST.pm index edef056..d27be7d 100644 --- a/lib/Catalyst/Action/REST.pm +++ b/lib/Catalyst/Action/REST.pm @@ -17,13 +17,14 @@ use Catalyst::Controller::REST; BEGIN { require 5.008001; } -our $VERSION = '0.73'; +our $VERSION = '0.79'; +$VERSION = eval $VERSION; sub new { my $class = shift; my $config = shift; Catalyst::Request::REST->_insert_self_into( $config->{class} ); - return $class->SUPER::new($config, @_); + return $class->next::method($config, @_); } =head1 NAME @@ -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 : Action { + ... 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,16 @@ for this to run smoothly. =back -=head1 MAINTAINER +=head1 AUTHOR -Hans Dieter Pearcey +Adam Jacob , with lots of help from mst and jrockway + +Marchex, Inc. paid me while I developed this module. (L) =head1 CONTRIBUTORS +Arthur Axel "fREW" Schmidt + Christopher Laco Luke Saunders @@ -200,13 +211,13 @@ Daisuke Maki J. Shirley -Tomas Doran (t0m) +Hans Dieter Pearcey -=head1 AUTHOR +Tomas Doran (t0m) -Adam Jacob , with lots of help from mst and jrockway +=head1 COPYRIGHT -Marchex, Inc. paid me while I developed this module. (L) +Copyright the above named AUTHOR and CONTRIBUTORS =head1 LICENSE