X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAction%2FDeserialize%2FYAML.pm;h=6f76a640c7247edf216e064324f4f398a1eaf580;hb=d4611771994693e9145e19c00c4b2d5bc7b485eb;hp=56ecb52740e17c1512a3a4896c3a74b321ea0bfd;hpb=256c894fcf95e1a0716676afb8f5732854734672;p=catagits%2FCatalyst-Action-REST.git diff --git a/lib/Catalyst/Action/Deserialize/YAML.pm b/lib/Catalyst/Action/Deserialize/YAML.pm index 56ecb52..6f76a64 100644 --- a/lib/Catalyst/Action/Deserialize/YAML.pm +++ b/lib/Catalyst/Action/Deserialize/YAML.pm @@ -12,21 +12,28 @@ use warnings; use base 'Catalyst::Action'; use YAML::Syck; -use Catalyst::Request::REST; sub execute { my $self = shift; my ( $controller, $c, $test ) = @_; - - my $nreq = bless($c->request, 'Catalyst::Request::REST'); - $c->request($nreq); - if ($c->request->method eq "POST" || $c->request->method eq "PUT") { - my $rdata = LoadFile($c->request->body); + + my $body = $c->request->body; + if ($body) { + my $rdata; + eval { + my $body = $c->request->body; + $rdata = LoadFile( "$body" ); + }; + if ($@) { + return $@; + } $c->request->data($rdata); - $self->NEXT::execute( @_, ); } else { - $self->NEXT::execute( @_ ); + $c->log->debug( + 'I would have deserialized, but there was nothing in the body!') + if $c->debug; } -}; + return 1; +} 1;