1 package Catalyst::Action::Deserialize::Callback;
4 use namespace::autoclean;
5 use Scalar::Util qw(openhandle);
7 extends 'Catalyst::Action';
13 my ( $controller, $c, $callbacks ) = @_;
17 # could be a string or a FH
18 if ( my $body = $c->request->body ) {
19 if(openhandle $body) {
20 seek($body, 0, 0); # in case something has already read from it
21 while ( defined( my $line = <$body> ) ) {
30 my $rdata = eval { $callbacks->{deserialize}->( $rbody, $controller, $c ) };
34 $c->request->data($rdata);
37 'I would have deserialized, but there was nothing in the body!')
43 __PACKAGE__->meta->make_immutable;