From: Wallace Reis Date: Fri, 22 Jun 2012 12:14:48 +0000 (+0200) Subject: Add default HEAD handler X-Git-Tag: 1.03~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Action-REST.git;a=commitdiff_plain;h=e566b7c797b76740ac385886bd717c5c82caea77 Add default HEAD handler Signed-off-by: Wallace Reis --- diff --git a/lib/Catalyst/Action/REST.pm b/lib/Catalyst/Action/REST.pm index 79cf340..bc715f6 100644 --- a/lib/Catalyst/Action/REST.pm +++ b/lib/Catalyst/Action/REST.pm @@ -118,6 +118,10 @@ sub _dispatch_rest_method { $name = $rest_method; $code = sub { $self->_return_options($self->name, @_) }; }, + HEAD => sub { + $rest_method =~ s{_HEAD$}{_GET}i; + $self->_dispatch_rest_method($c, $rest_method); + }, default => sub { # Otherwise, not implemented. $name = $self->name . "_not_implemented"; @@ -126,7 +130,9 @@ sub _dispatch_rest_method { || sub { $self->_return_not_implemented($self->name, @_) }; }, }; - ($code_action->{$req->method} || $code_action->{'default'})->(); + my $respond = ($code_action->{$req->method} + || $code_action->{'default'})->(); + return $respond unless $name; } # localise stuff so we can dispatch the action 'as normal, but get