diff options
author | franck cuny <franck@lumberjaph.net> | 2010-06-02 11:37:02 +0200 |
---|---|---|
committer | franck cuny <franck@lumberjaph.net> | 2010-06-02 11:37:02 +0200 |
commit | 0ce9554937e19d7c0045a68bc0c4184c84c236c4 (patch) | |
tree | c748e4eb75ca199f1d8e4abc32e0b8d32ac3fa92 | |
parent | parser to (de)serialize content (diff) | |
download | moosex-net-api-0ce9554937e19d7c0045a68bc0c4184c84c236c4.tar.gz |
role to handle useragent
-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__ |