diff --git a/lib/MetaCPAN/Server/Controller/Rating.pm b/lib/MetaCPAN/Server/Controller/Rating.pm index 9511497be..74233ddfe 100644 --- a/lib/MetaCPAN/Server/Controller/Rating.pm +++ b/lib/MetaCPAN/Server/Controller/Rating.pm @@ -28,17 +28,17 @@ sub _mapping : Path('_mapping') : Args(0) { $c->detach('/not_found'); } -sub find : Path('_search') : Args(0) { +sub find : Path('_search') : Args(0) : ActionClass('~Deserialize') { my ( $self, $c, $scroll ) = @_; my @hits; # fake results for MetaCPAN::Client so it doesn't fail its tests - if ( ( $c->req->user_agent // '' ) - =~ m{^MetaCPAN::Client-testing/([0-9.]+)} ) - { + if ( ( $c->req->user_agent // '' ) =~ m{^MetaCPAN::Client/([0-9.]+)} ) { if ( $1 <= 2.031001 ) { - my $query = $c->read_param('query'); + use Data::Dumper; + warn Dumper($c->req->params); + my $query = $c->req->params->{'query'}; if ( $query && $query->[0] && $query->[0]{term} @@ -72,7 +72,7 @@ sub find : Path('_search') : Args(0) { } ); } -sub all : Path('') : Args(0) { +sub all : Path('') : Args(0) : ActionClass('~Deserialize') { my ( $self, $c ) = @_; $c->forward('find'); } diff --git a/t/server/controller/rating.t b/t/server/controller/rating.t index 3fff7b65a..778eb1511 100644 --- a/t/server/controller/rating.t +++ b/t/server/controller/rating.t @@ -92,7 +92,8 @@ test_psgi app, sub { ok( $res = $cb->( POST '/rating/_search', - 'User-Agent' => 'MetaCPAN::Client-testing/2.031001', + 'User-Agent' => 'MetaCPAN::Client/2.031001', + 'Content-Type' => 'application/json', Content => '{"query":{"term":{"distribution":"Moose"}}}', ), 'POST /rating with MetaCPAN::Client test UA'