summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-09-15 18:16:11 +0200
committerfranck cuny <franck@lumberjaph.net>2010-09-15 18:16:11 +0200
commitc7643d26a69c84632a0b6d88360b35c5d82a625b (patch)
treea1c2590bbb4a75778fbc0fa2f8f966f3074589d7
parentnew role to load (diff)
downloadnet-http-spore-c7643d26a69c84632a0b6d88360b35c5d82a625b.tar.gz
auth format remove proto
-rw-r--r--lib/Net/HTTP/Spore/Meta/Method.pm34
1 files changed, 21 insertions, 13 deletions
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);