| Catalyst-Action-Serialize-XML-Hash-LX documentation | Contained in the Catalyst-Action-Serialize-XML-Hash-LX distribution. |
Catalyst::Action::Deserialize::XML::Hash::LX - XML::Hash::LX deserializer for Catalyst
package Foo::Controller::Bar;
__PACKAGE__->config(
default => 'text/xml',
map => {
'text/xml' => 'XML::Hash::LX',
# or
'text/xml' => [ 'XML::Hash::LX', { XML::Hash::LX options } ],
},
)
sub begin : ActionClass('Deserialize') {}
XML::Hash::LX deserializer for Catalyst::Action::Deserialize
Mons Anderson, <mons at cpan.org>
Copyright 2009 Mons Anderson, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Catalyst-Action-Serialize-XML-Hash-LX documentation | Contained in the Catalyst-Action-Serialize-XML-Hash-LX distribution. |
# # Catlyst::Action::Deserialize::XML::Hash::LX.pm # Created by: Mons Anderson, <mons@cpan.org> # # $Id$ package Catalyst::Action::Deserialize::XML::Hash::LX;
use strict; use warnings; use base 'Catalyst::Action'; use XML::Hash::LX 'xml2hash'; our $VERSION = '0.06'; sub execute { my $self = shift; my ( $controller, $c, $opts ) = @_; my $body = $c->request->body; my $rbody; if ($body) { while (my $line = <$body>) { $rbody .= $line; } } if ( $rbody ) { warn "Hash::LX deserialize"; my $rdata = eval { xml2hash( $rbody, $opts ? ( ref $opts eq 'ARRAY' ? @$opts : %$opts ) : () ) }; return $@ if $@; $c->request->data($rdata); } else { $c->log->debug('I would have deserialized, but there was nothing in the body!') if $c->debug; } return 1; }
1;