Skip to content

Instantly share code, notes, and snippets.

@jjn1056
Created September 5, 2010 23:03
Show Gist options
  • Select an option

  • Save jjn1056/566415 to your computer and use it in GitHub Desktop.

Select an option

Save jjn1056/566415 to your computer and use it in GitHub Desktop.
use CatalystX::Declare;
namespace MyApp::Web::Controller;
controller ::API::Photos {
extends 'Catalyst::Controller::DBIC::API::REST';
$CLASS->config(
default => 'text/xml',
class => 'Schema::Photo',
page_arg => 'page',
count_arg => 'count',
ordered_by_arg => 'sort',
search_arg => 'search',
prefetch_arg => 'prefetch',
ordered_by => {-asc=>'title'},
prefetch_allows => [qw/keywords_photo_rs/],
page => 1,
count => 25,
'map' => {
'text/xml' => 'XML::Simple',
},
);
action setup
under '/api/api_base'
as 'photos';
around item($ctx) {
$self->$orig($ctx);
my $url = $ctx->uri_for_action(
'/api/keywords/list_objects', {
'search.keyword_photos_rs.fk_photo_id' => $ctx->stash->{response}->{data}->{photo_id},
});
$ctx->stash->{response}->{keywords} = {href=>"$url"};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment