From: Dave Rolsky Date: Sat, 22 Jan 2011 15:57:30 +0000 (-0600) Subject: Changes to accommodate Action::REST::ForBrowsers X-Git-Tag: 0.89~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Action-REST.git;a=commitdiff_plain;h=bc06b9a375c0c35d1f1248e618148afd70c165b9 Changes to accommodate Action::REST::ForBrowsers --- diff --git a/lib/Catalyst/Request/REST.pm b/lib/Catalyst/Request/REST.pm index 0dacfc6..d6b14d1 100644 --- a/lib/Catalyst/Request/REST.pm +++ b/lib/Catalyst/Request/REST.pm @@ -23,7 +23,7 @@ sub _insert_self_into { my $req_class = $app->request_class; return if $req_class->isa($class); my $req_class_meta = Moose->init_meta( for_class => $req_class ); - my $role = $self->_related_role; + my $role = $class->_related_role; return if $req_class_meta->does_role($role); if ($req_class eq 'Catalyst::Request') { $app->request_class($class); diff --git a/lib/Catalyst/Request/REST/ForBrowsers.pm b/lib/Catalyst/Request/REST/ForBrowsers.pm index cf4a153..7b119c8 100644 --- a/lib/Catalyst/Request/REST/ForBrowsers.pm +++ b/lib/Catalyst/Request/REST/ForBrowsers.pm @@ -9,6 +9,8 @@ $VERSION = eval $VERSION; extends 'Catalyst::Request::REST'; with 'Catalyst::TraitFor::Request::REST::ForBrowsers'; +sub _related_role { 'Catalyst::TraitFor::Request::REST::ForBrowsers' } + __PACKAGE__->meta->make_immutable; 1; diff --git a/t/lib/Test/Rest.pm b/t/lib/Test/Rest.pm index 704cff2..854e5c8 100644 --- a/t/lib/Test/Rest.pm +++ b/t/lib/Test/Rest.pm @@ -26,8 +26,15 @@ sub new { my $sub = lc($method); *$sub = sub { my $self = shift; - my %p = validate( @_, { url => { type => SCALAR }, }, ); + my %p = validate( + @_, + { + url => { type => SCALAR }, + headers => { type => HASHREF, default => {} }, + }, + ); my $req = HTTP::Request->new( "$method" => $p{'url'} ); + $req->header( $_ => $p{headers}{$_} ) for keys %{ $p{headers} }; $req->content_type( $self->{'content_type'} ); return $req; }; @@ -44,9 +51,11 @@ sub new { { url => { type => SCALAR }, data => 1, + headers => { type => HASHREF, default => {} }, }, ); my $req = HTTP::Request->new( "$method" => $p{'url'} ); + $req->header( $_ => $p{headers}{$_} ) for keys %{ $p{headers} }; $req->content_type( $self->{'content_type'} ); $req->content_length( do { use bytes; length( $p{'data'} ) }