[Catalyst] Error in subclassing Catalyst::Controller::DBIC::API::REST

Fitz Elliott felliott at virginia.edu
Wed Jun 24 13:00:43 GMT 2009

Hey Amiri,

> Now for the problem. When I go to test this:
>    my $mech = Test::WWW::Mechanize::Catalyst->new;
>    ok(my $schema = DBICTest->init_schema(), 'got schema');
>      my $req = GET("http://localhost/api/rest/artist/list", {
>      }, 'Accept' => 'text/x-json' );
>      $mech->request($req);
>      cmp_ok( $mech->status, '==', 200, 'open attempt okay' );

I just finished building some code around C::C::DBIC::API and ran  
into something similar. I'm assuming in this test that you are trying  
to get a list of all artists.  If so, you should make a GET request  
against http://localhost/api/rest/artist.   In a REST controller,  
artist/list would be asking for the artist whose id is 'list'.     
C::C::DBIC::API also doesn't support GET on an individual object out  
of the box, but it is easy to add.  Just add

   sub object_GET :Private {}

in RestTest::ControllerBase::REST.  The rest of the code is already  
there to retrieve the object and serialize it.


More information about the Catalyst mailing list