Role::REST::Client::Auth::Basic - Basic Authentication for REST Client Role
version 0.05
{ package RESTExample; use Moose; with 'Role::REST::Client'; with 'Role::REST::Client::Auth::Basic'; sub bar { my ($self) = @_; my $res = $self->post('foo/bar/baz', {foo => 'bar'}); my $code = $res->code; my $data = $res->data; return $data if $code == 200; } } my $foo = RESTExample->new( server => 'http://localhost:3000', type => 'application/json', user => 'mee', passwd => 'sekrit', ); $foo->bar; # controller sub foo : Local { my ($self, $c) = @_; # Call w/ basic authentication my $res = $c->model('MyData')->post('foo/bar/baz', {foo => 'bar'}); my $code = $res->code; my $data = $res->data; ... # Call w/o basic authentication my $res = $c->model('MyData')->post('xyzzy', {foo => 'bar'}, {authentication => undef}); }
This role adds basic authentication to Role::REST::Client.
Just add it to your class and all calls will automatically authenticate.
Add an authentication parameter to the arguments if you for some reaon don't want to authenticate
Kaare Rasmussen, <kaare at cpan dot com>
Aran Deltac, (cpan:BLUEFEET) <bluefeet@gmail.com>
Please report any bugs or feature requests to bug-role-rest-client-auth-basic at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Role-REST-Client-Auth-Basic.
Copyright 2014 Kaare Rasmussen, all rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
Kaare Rasmussen <kaare at cpan dot net>
This software is copyright (c) 2014 by Kaare Rasmussen.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Role::REST::Client::Auth::Basic, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Role::REST::Client::Auth::Basic
CPAN shell
perl -MCPAN -e shell install Role::REST::Client::Auth::Basic
For more information on module installation, please visit the detailed CPAN module installation guide.