NAME

Clustericious::Plugin::AutodataHandler - Handle data types automatically

VERSION

version 1.29

SYNOPSIS

 package YourApp::Routes;
 
 use Clustericious::RouteBuilder;
 
 get '/some/route' => sub {
   my $c = shift;
   $c->stash->{autodata} = { x => 1, y => 'hello, z => [1,2,3] };
 };

DESCRIPTION

Adds a renderer that automatically serializes that "autodata" in the stash into a format based on HTTP Accept and Content-Type headers. Also adds a helper called parse_autodata that handles incoming data by Content-Type.

Supports application/json, text/x-yaml and application/x-www-form-urlencoded (in-bound only).

When parse_autodata is called from within a route like this:

 $self->parse_autodata;

POST data is parsed according to the type in the 'Content-Type' header with the data left in stash->{autodata}. It is also returned by the above call.

If a route leaves data in stash->{autodata}, it is rendered by this handler, which chooses the type with the first acceptable type listed in the Accept header, the Content-Type header, or the default. (By default, the default is application/json, but you can override that too).

AUTHOR

Original author: Brian Duggan

Current maintainer: Graham Ollis <plicease@cpan.org>

Contributors:

Curt Tilmes

Yanick Champoux

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by NASA GSFC.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.