Hi,

I'm using Catalyst-Controller-DBIC-API to provide some RESTful webservices
- at the moment it is set up as per the cpan docs:

/api/rest/superfamily            # lists all "superfamily" objects
/api/rest/superfamily/1.10.8.10  # list a single "superfamily" object
/api/rest/domain                 # lists all "domain" objects
/api/rest/domain/1abcA01         # list a single "domain" object

NB: a "domain" belongs to a "superfamily".

I also want to set up some chained uris to make common queries more
readable and avoid typos, e.g.

# list all the domains in superfamily "1.10.8.10"
/api/rest/superfamily/1.10.8.10/domain

I couldn't see any docs that specifically deal with this - so at the moment
I'm working on the basis that I need create an end point for the above path
and turn it into a request for:

/api/rest/domain?search.superfamily_id=1.10.8.10

Since I need to mess with the request params I figured I need to do this
via a full SubRequest - something like...

package MyApp::Controller::API::REST::Superfamily::Domain;
use Moose;
BEGIN { extends 'Catalyst::Controller' }

sub base :Chained( '/api/rest/superfamily/base_with_id' ) PathPart(
'domain' ) CaptureArgs(0) {
        my ($self, $c) = @_;
}

sub list :Chained( 'base') PathPart('') Args(0) {
        my ($self, $c) = @_;
        my $res = $c->subreq_res(
                        $c->uri_for_action( '/api/rest/domain/list_objects'
)->path,
                        {},
                        {
                                'search.superfamily_id' =>
$c->stash->{superfamily_id},
                        });

        $c->response->headers( $res->headers );
        $c->response->body( $res->body );
}


However, this seems a bit messy (although perhaps marginally less messy
then overwriting the current request params, then forwarding) - is there a
better way of achieving this kind of thing?

Many thanks,

-- 
Ian Sillitoe
Orengo Group, Structural and Molecular Biology
University College London
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to