Why not adopt me?
NAME
Net::Async::Webservice::Common::WithRequestWrapper - helper methods to perform HTTP request
VERSION
version 1.0.2
SYNOPSIS
package
My::WS::Client {
}
my
$loop
= IO::Async::Loop->new;
my
$c
= My::WS::Client->new({
loop
=>
$loop
});
my
(
$response_body
) =
@_
;
say
"Got <$response_body>"
;
return
Future->wrap();
})->get;
DESCRIPTION
This role provides a few methods to perform HTTP requests via a user_agent
attribute / method (which is required, and could be provided by Net::Async::Webservice::Common::WithUserAgent or any other means).
Failures (both during connection, and as signaled by the HTTP response codes) are wrapped in Net::Async::Webservice::Common::Exception::HTTPError and returned as failed futures. On success, the future yields the decoded content of the response.
ATTRIBUTES
ssl_options
Optional hashref, its contents will be passed to user_agent
's do_request
method.
METHODS
request
$c
->request(
$http_request
) ==>
$decoded_content
Performs the given request via the user_agent
, with fail_on_error
set; if the request succeeds, the returned future will yield the decoded content of the response. If the request fails, the future will fail with a two-element failure: a Net::Async::Webservice::Common::Exception::HTTPError and the string 'webservice'
.
post
$c
->post(
$url
,
$body
) ==>
$decoded_content
Shortcut to submit a very basic POST request. The $body
will be UTF-8 encoded, no headers are set. Uses "request" to perform the actual request.
get
$c
->get(
$url
) ==>
$decoded_content
Shortcut to submit a very basic GET request. No headers are set. Uses "request" to perform the actual request.
AUTHOR
Gianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Net-a-porter.com.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.