Graham Ollis > Clustericious > Clustericious::Plugin::AutodataHandler

Download:
Clustericious-0.9936.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.9936   Source  

NAME ^

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

VERSION ^

version 0.9936

SYNOPSIS ^

 package YourApp::Routes;
 
 use Clustericious::RouteBuilder;
 
 get '/some/route' => sub {
   my $c = shift;
   $c->{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

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.

syntax highlighting: