The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mojo::Pua - HTTP Client + Evo::Promises

VERSION

version 0.006

SYNOPSIS

Mojo::Pua inherits all methods from Mojo::UserAgent but returns Mojo::Promise object for each request

  use Evo 'Mojo::Pua';
  my $ua = Mojo::Pua->new();

  $ua->get("http://alexbyk.com/")

    ->then(sub($res) { say $res->dom->at('title') })

    ->catch(sub($err) { say "ERR: $err"; say $err->res->body if $err->res; })

    ->finally(sub { Mojo::IOLoop->stop; });

  Mojo::IOLoop->start;

DESCRIPTION

!!!ATTENTION This is first temporary release. Use it on your own risk.

This module is based on Mojo::UserAgent and allows you to use promises (Evo::Promise)

LIB version SYNOPSIS

  use Evo 'Mojo::Pua *; Mojo::IOLoop';

  pua_get('http://alexbyk.com/')

    ->then(sub($res) { say $res->dom->at('title') })

    ->catch(sub($err) { say "$err"; $err->res and say $err->res->body })

    ->finally(sub { Mojo::IOLoop->stop });


  Mojo::IOLoop->start;

FUNCTIONS

pua_delete

pua_get

pua_head

pua_options

pua_patch

pua_post

pua_put

Perform non-blocking request and return a promise object. See Mojo::UserAgent, because this module right now is based on it See https://github.com/alexbyk/mojo-pua "examples" for more examples

SEE ALSO

Mojo::UserAgent Mojo::Promise https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise

AUTHOR

alexbyk <alexbyk.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by alexbyk.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.