Clustericious::Plugin::AutodataHandler - Handle data types automatically
version 1.29
package YourApp::Routes; use Clustericious::RouteBuilder; get '/some/route' => sub { my $c = shift; $c->stash->{autodata} = { x => 1, y => 'hello, z => [1,2,3] }; };
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.
parse_autodata
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).
Original author: Brian Duggan
Current maintainer: Graham Ollis <plicease@cpan.org>
Contributors:
Curt Tilmes
Yanick Champoux
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.
To install Clustericious, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Clustericious
CPAN shell
perl -MCPAN -e shell install Clustericious
For more information on module installation, please visit the detailed CPAN module installation guide.