Ash Berlin > Net-HTTP-Spore-0.06 > Net::HTTP::Spore::Middleware::Format

Download:
Net-HTTP-Spore-0.06.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.06   Source  

NAME ^

Net::HTTP::Spore::Middleware::Format - base class for formats middlewares

VERSION ^

version 0.06

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 ^

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.

syntax highlighting: