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 and other shared code resides.

EXPORTS

FUNCTIONS

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] 

_is_authorized

This function does the actual work for is_authorized in the Dispatch.pm module of an App::MFILE::WWW-based application.

This function belongs in Dispatch.pm - it is here only to prevent code duplication.

_is_fresh

Takes a single argument, the PSGI session, which is assumed to contain a last_seen attribute containing the number of seconds since epoch when the session was last seen.