1 package Catalyst::Action::Deserialize::XML::Simple;
4 use namespace::autoclean;
5 use Scalar::Util qw(openhandle);
7 extends 'Catalyst::Action';
10 $VERSION = eval $VERSION;
14 my ( $controller, $c, $test ) = @_;
20 $c->log->debug("Could not load XML::Simple, refusing to deserialize: $@")
25 my $body = $c->request->body;
27 my $xs = XML::Simple->new('ForceArray' => 0,);
30 if(openhandle $body){ # make sure we rewind the file handle
31 seek($body, 0, 0); # in case something has already read from it
33 $rdata = $xs->XMLin( $body );
38 if (exists($rdata->{'data'})) {
39 $c->request->data($rdata->{'data'});
41 $c->request->data($rdata);
45 'I would have deserialized, but there was nothing in the body!')
51 __PACKAGE__->meta->make_immutable;