Torsten Raudssus > Reflexive-Client-HTTP > Reflexive::Client::HTTP::Role

Download:
Reflexive-Client-HTTP-0.007.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.007   Source  

NAME ^

Reflexive::Client::HTTP::Role - A role for automatically getting a watched Reflexive::Client::HTTP

VERSION ^

version 0.007

SYNOPSIS ^

  {
    package MySampleClient;

    use Moose;
    with 'Reflexive::Client::HTTP::Role';

    sub on_http_response {
      my ( $self, $response_event ) = @_;
      my $http_response = $response_event->response;
      my ( $who ) = @{$response_event->args};
      print $who." got status ".$http_response->code."\n";
    }

    sub request {
      my ( $self, $who ) = @_;
      $self->http_request( HTTP::Request->new( GET => 'http://www.duckduckgo.com/' ), $who );
    }
  }

  my $msc = MySampleClient->new;
  $msc->request('peter');
  $msc->request('paul');
  $msc->request('marry');

  Reflex->run_all();

DESCRIPTION ^

If you attach this role, your Moose class gets an additional attribute http which contains a Reflexive::Client::HTTP. This allows you to add a simple on_http_response method, which gets the Reflexive::Client::HTTP::ResponseEvent on the success of a previous executed call to "http_request".

ATTRIBUTES ^

http

This watched attribute containts the Reflexive::Client::HTTP. It handles "http_request" which triggers "request" in Reflexive::Client::HTTP.

http_options

This HashRef is used for constructing the Reflexive::Client::HTTP in "http".

METHODS ^

http_request

See "request" in Reflexive::Client::HTTP.

AUTHOR ^

Torsten Raudssus <torsten@raudss.us>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2012 by Torsten Raudssus.

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: