NAME

LWP::UserAgent::Caching::Simple - The first 'hard thing' made easy --- simple

VERSION

Version 0.03

SYNOPSIS

use LWP::UserAgent::Caching::Simple;

my $ua = LWP::UserAgent::Caching::Simple->new;

my $resp = $ua->get( 'http://example.com/cached?' );

and maybe even something quick:

# use a built-in default User-Agent for quick one timers

use LWP::UserAgent::Caching::Simple qw(get_from_json);

my $hashref = get_from_json ( 'http://example.com/cached?' );

DESCRIPTION

This is a simplified version of LWP::UserAgent::Caching with sensible defaults and less options. For more control and more options, please use that module.

METHODS

Since this is a subclass of LWP::UserAgent::Caching it has it's methods, like the following object methods:

request
get
post
put
delete

And to make life realy simpel, when imported, one function

get_from_json

this will simply make a GET request to a server, with the Accept Header set to application/json. On succes, it will turn the returned json (as requested) into a perl data structure. Otherwise it will be undef and print a warning.

CAVEATS

This is a super simplified way of making straightforward request. It can handle mnore complex requests as well, using

my $resp = $ua->request($http_rqst);

which will give a full HTTP::Response object back. The UserAgent is a full subclass of the standard LWP::UserAgent, and one can still change the setting of that, like e.g. the <$ua-agent('SecretAgent/007')>>. But if you need more control over your cache, you definitly need to fall back to LWP::UserAgent::Caching

AUTHOR

Theo van Hoesel, <Th.J.v.Hoesel at THEMA-MEDIA.nl>

LICENSE AND COPYRIGHT

Copyright 2016 Theo van Hoesel.