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