diff options
Diffstat (limited to 'lib/MooseX/Net/API')
-rw-r--r-- | lib/MooseX/Net/API/Role/UserAgent.pm | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/MooseX/Net/API/Role/UserAgent.pm b/lib/MooseX/Net/API/Role/UserAgent.pm new file mode 100644 index 0000000..0c11732 --- /dev/null +++ b/lib/MooseX/Net/API/Role/UserAgent.pm @@ -0,0 +1,24 @@ +package MooseX::Net::API::Role::UserAgent; + +use Moose::Role; +use LWP::UserAgent; + +has api_useragent => ( + is => 'rw', + isa => 'LWP::UserAgent', + lazy => 1, + default => sub { + my $self = shift; + my $ua = $self->meta->get_option('useragent'); + return $ua->() if $ua; + $ua = LWP::UserAgent->new(); + $ua->agent( + "MooseX::Net::API " . $MooseX::Net::API::VERSION . " (Perl)"); + $ua->env_proxy; + return $ua; + } +); + +1; + +__END__ |