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

App::MFILE::HTTP - general REST request forwarder for MFILE-based clients

SYNOPSIS

    use App::MFILE::HTTP qw( rest_req );

DESCRIPTION

Module where rest_req resides.

EXPORTS

FUNCTIONS

init_ua

Initialize a LWP::UserAgent singleton object.

Takes two _mandatory_ parameters:

    - a LWP::UserAgent object
    - a scalar (filename of cookie jar)

rest_req

Algorithm: send request to REST server, get JSON response, decode it, return it.

Takes a single _mandatory_ parameter: a LWP::UserAgent object

Optionally takes PARAMHASH:

    server => [URI OF REST SERVER]         default is 'http://0:5000'
    method => [HTTP METHOD TO USE]         default is 'GET'
    nick => [NICK FOR BASIC AUTH]          optional
    password => [PASSWORD FOR BASIC AUTH]  optional
    path => [PATH OF REST RESOURCE]        default is '/'
    req_body => [HASHREF]                  optional

Returns HASHREF containing:

    hr => HTTP::Response object (stripped of the body)
    body => [BODY OF HTTP RESPONSE, IF ANY]