| 1 | package Data::Riak::HTTP::Request; | ||
| 2 | { | ||
| 3 | $Data::Riak::HTTP::Request::VERSION = '2.0'; | ||
| 4 | } | ||
| 5 | |||
| 6 | use strict; | ||
| 7 | use warnings; | ||
| 8 | |||
| 9 | use Moose; | ||
| 10 | |||
| 11 | use HTTP::Headers::ActionPack::LinkList; | ||
| 12 | |||
| 13 | with 'Data::Riak::Transport::Request'; | ||
| 14 | |||
| 15 | has method => ( | ||
| 16 | is => 'ro', | ||
| 17 | isa => 'Str', | ||
| 18 | required => 1, | ||
| 19 | ); | ||
| 20 | |||
| 21 | has uri => ( | ||
| 22 | is => 'ro', | ||
| 23 | isa => 'Str', | ||
| 24 | required => 1 | ||
| 25 | ); | ||
| 26 | |||
| 27 | has query => ( | ||
| 28 | is => 'ro', | ||
| 29 | isa => 'HashRef', | ||
| 30 | predicate => 'has_query' | ||
| 31 | ); | ||
| 32 | |||
| 33 | has data => ( | ||
| 34 | is => 'ro', | ||
| 35 | isa => 'Str', | ||
| 36 | default => '' | ||
| 37 | ); | ||
| 38 | |||
| 39 | has links => ( | ||
| 40 | is => 'ro', | ||
| 41 | isa => 'HTTP::Headers::ActionPack::LinkList', | ||
| 42 | # TODO: make this coerce | ||
| 43 | default => sub { | ||
| 44 | return HTTP::Headers::ActionPack::LinkList->new; | ||
| 45 | } | ||
| 46 | ); | ||
| 47 | |||
| 48 | has indexes => ( | ||
| 49 | is => 'ro', | ||
| 50 | isa => 'ArrayRef[HashRef]' | ||
| 51 | ); | ||
| 52 | |||
| 53 | has content_type => ( | ||
| 54 | is => 'ro', | ||
| 55 | isa => 'Str', | ||
| 56 | default => 'text/plain' | ||
| 57 | ); | ||
| 58 | |||
| 59 | has accept => ( | ||
| 60 | is => 'ro', | ||
| 61 | isa => 'Str', | ||
| 62 | default => '*/*' | ||
| 63 | ); | ||
| 64 | |||
| 65 | has headers => ( | ||
| 66 | is => 'ro', | ||
| 67 | isa => 'HashRef', | ||
| 68 | lazy => 1, | ||
| 69 | builder => '_build_headers', | ||
| 70 | ); | ||
| 71 | |||
| 72 | sub _build_headers { +{} } | ||
| 73 | |||
| 74 | sub BUILD { | ||
| 75 | my ($self) = @_; | ||
| 76 | $self->headers; | ||
| 77 | } | ||
| 78 | |||
| 79 | __PACKAGE__->meta->make_immutable; | ||
| 80 | no Moose; | ||
| 81 | |||
| 82 | 1; | ||
| 83 | |||
| 84 | __END__ |