From c7643d26a69c84632a0b6d88360b35c5d82a625b Mon Sep 17 00:00:00 2001 From: franck cuny Date: Wed, 15 Sep 2010 18:16:11 +0200 Subject: auth format remove proto --- lib/Net/HTTP/Spore/Meta/Method.pm | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'lib/Net/HTTP/Spore') diff --git a/lib/Net/HTTP/Spore/Meta/Method.pm b/lib/Net/HTTP/Spore/Meta/Method.pm index 0087147..3494350 100644 --- a/lib/Net/HTTP/Spore/Meta/Method.pm +++ b/lib/Net/HTTP/Spore/Meta/Method.pm @@ -23,31 +23,35 @@ has method => ( is => 'ro', isa => 'Method', required => 1 ); has description => ( is => 'ro', isa => 'Str', predicate => 'has_description' ); has authentication => ( - is => 'ro', - isa => 'Bool', + is => 'ro', + isa => 'Bool', predicate => 'has_authentication', - default => 0 + default => 0 ); -has api_base_url => ( +has base_url => ( is => 'ro', isa => Uri, coerce => 1, - predicate => 'has_api_base_url', + predicate => 'has_base_url', +); +has format => ( + is => 'ro', + isa => 'ArrayRef', + isa => ArrayRef [Str], + predicate => 'has_format', ); has expected => ( traits => ['Array'], is => 'ro', isa => ArrayRef [Int], auto_deref => 1, - required => 0, predicate => 'has_expected', - handles => {find_expected_code => 'grep',}, + handles => { find_expected_code => 'grep', }, ); has params => ( traits => ['Array'], is => 'ro', isa => ArrayRef [Str], - required => 0, default => sub { [] }, auto_deref => 1, handles => {find_request_parameter => 'first',} @@ -58,7 +62,6 @@ has required => ( isa => ArrayRef [Str], default => sub { [] }, auto_deref => 1, - required => 0, ); has documentation => ( is => 'ro', @@ -111,9 +114,14 @@ sub wrap { push @$params, $_, $method_args{$_}; } + my $authentication = + $method->has_authentication ? $method->authentication : $self->authentication; + + my $format = $method->has_format ? $method->format : $self->api_format; + my $api_base_url = - $method->has_api_base_url - ? $method->api_base_url + $method->has_base_url + ? $method->base_url : $self->api_base_url; my $env = { @@ -128,14 +136,14 @@ sub wrap { PATH_INFO => $method->path, REQUEST_URI => '', QUERY_STRING => '', - SERVER_PROTOCOL => $api_base_url->scheme, HTTP_USER_AGENT => $self->api_useragent->agent, 'spore.expected' => [ $method->expected ], - 'spore.authentication' => $method->authentication, + 'spore.authentication' => $authentication, 'spore.params' => $params, 'spore.payload' => $payload, 'spore.errors' => *STDERR, 'spore.url_scheme' => $api_base_url->scheme, + 'spore.format' => $format, }; my $response = $self->http_request($env); -- cgit 1.4.1