1 package Catalyst::Action::Deserialize::XML::Simple;
4 use namespace::autoclean;
5 use Scalar::Util qw(openhandle);
7 extends 'Catalyst::Action';
13 my ( $controller, $c, $test ) = @_;
19 $c->log->debug("Could not load XML::Simple, refusing to deserialize: $@")
24 my $body = $c->request->body;
26 my $xs = XML::Simple->new('ForceArray' => 0,);
29 if(openhandle $body){ # make sure we rewind the file handle
30 seek($body, 0, 0); # in case something has already read from it
32 $rdata = $xs->XMLin( $body );
37 if (exists($rdata->{'data'})) {
38 $c->request->data($rdata->{'data'});
40 $c->request->data($rdata);
44 'I would have deserialized, but there was nothing in the body!')
50 __PACKAGE__->meta->make_immutable;