Created
September 5, 2010 23:03
-
-
Save jjn1056/566415 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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