X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-HTTP-AnyUA;a=blobdiff_plain;f=lib%2FHTTP%2FAnyUA%2FBackend%2FMojo%2FUserAgent.pm;h=aeb2b1f5838c3362d9517eec9a68557b860c0d9c;hp=436eddf4ee61dc63d19146c946599c233a67248e;hb=8306d573a50cbac0d76bf01ce98e82beec36e42d;hpb=950a5203bb27c21b549742ce3dec05df1e331b59 diff --git a/lib/HTTP/AnyUA/Backend/Mojo/UserAgent.pm b/lib/HTTP/AnyUA/Backend/Mojo/UserAgent.pm index 436eddf..aeb2b1f 100644 --- a/lib/HTTP/AnyUA/Backend/Mojo/UserAgent.pm +++ b/lib/HTTP/AnyUA/Backend/Mojo/UserAgent.pm @@ -6,6 +6,9 @@ package HTTP::AnyUA::Backend::Mojo::UserAgent; This module adds support for the HTTP client L to be used with the unified programming interface provided by L. +If installed, requests will return L rather than L. This allows the use of the +C<< ->get >> method to await a result. + =head1 CAVEATS =for :list @@ -29,13 +32,21 @@ use Future; use Scalar::Util; +my $future_class; +BEGIN { + $future_class = 'Future'; + eval 'use Future::Mojo'; ## no critic + $future_class = 'Future::Mojo' if !$@; +} + + sub response_is_future { 1 } sub request { my $self = shift; my ($method, $url, $args) = @_; - my $future = Future->new; + my $future = $future_class->new; my $tx = $self->_munge_request(@_);