NAME
Net::HTTP::Spore::Middleware::Format - base class for formats middlewares
VERSION
version 0.09
SYNOPSIS
my $client = Net::HTTP::Spore->new_from_spec('twitter.json');
$client->enable('Format::JSON');
my $res = $client->public_timeline();
# $res->body contains an hashref build from the JSON returned by the API
DESCRPITION
This middleware is a base class for others format's middleware. Thoses middlewares must set the appropriate Content-Type and Accept header to the request.
If the environment contains a payload (under the name 'spore.payload'), it should also serialize this data to the appropriate format (eg: if payload contains an hashref, and the format is json, the hashref MUST be serialized to JSON).
METHODS
- serializer_key
-
name of the extension serializer should check to be sure to not encode a payload already encoded, or set the headers that have already been defined
- deserializer_key
-
as previously, but for the response instead of the request
- encode
-
this method MUST be implemented in class extending this one. This method MUST return an encoded string from the argument passed.
- decode
-
this method MUST be implemented in class extending this one. This method MUST return a reference from the undecoded string passed as argument.
- accept_type
-
this method MUST be implemented in class extending this one. This method MUST return a string that will be used as the Accept HTTP header.
- content_type
-
this method MUST be implemented in class extending this one. This method MUST return a string that will be used as the Content-Type HTTP header.
- should_serialize
-
this method returns 1 if serialization have not already been done
- should_deserialize
-
this method returns 1 if deserialization have not already been done
- call
AUTHORS
Franck Cuny <franck.cuny@gmail.com>
Ash Berlin <ash@cpan.org>
Ahmad Fatoum <athreef@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Linkfluence.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.