NAME
Catalyst::Controller::Resources - Catalyst Collection Resources Controller
SYNOPSIS
MAP RESOURCES
package MyApp::Controller::Articles;
use base 'Catalyst::Controller::Resources';
# GET /articles
sub list {
my ($self, $c) = @_;
}
# POST /articles
sub create {
my ($self, $c) = @_;
}
# GET /articles/{article_id}
sub show {
my ($self, $c, $article_id) = @_;
}
# PUT /articles/{article_id}
sub update {
my ($self, $c, $article_id) = @_;
}
# DELETE /articles/{article_id}
sub destroy {
my ($self, $c, $article_id) = @_;
}
# GET /articles/new
sub post {
my ($self, $c) = @_;
}
# GET /articles/{article_id}/edit
sub edit {
my ($self, $c, $article_id) = @_;
}
NESTED RESOURCES
package MyApp::Controller::Articles;
use base 'Catalyst::Controller::Resources';
# ...
package MyApp::Controller::Comments;
use base 'Catalyst::Controller::Resources';
__PACKAGE__->config(belongs_to => 'Articles');
# GET /articles/{article_id}/comments
sub list {
my ($self, $c, $article_id) = @_;
}
# POST /articles/{article_id}/comments
sub create {
my ($self, $c, $article_id) = @_;
}
# GET /articles/{article_id}/comments/{comment_id}
sub show {
my ($self, $c, $article_id, $comment_id) = @_;
}
# PUT /articles/{article_id}/comments/{comment_id}
sub update {
my ($self, $c, $article_id, $comment_id) = @_;
}
# DELETE /articles/{article_id}/comments/{comment_id}
sub destroy {
my ($self, $c, $article_id, $comment_id) = @_;
}
# GET /articles/{article_id}/comments/new
sub post {
my ($self, $c, $article_id) = @_;
}
# GET /articles/{article_id}/comments/{comment_id}/edit
sub edit {
my ($self, $c, $article_id, $comment_id) = @_;
}
DESCRIPTION
This controller defines HTTP verb-oriented actions for collection resource, inspired by map.resources (Ruby on Rails).
In your controller:
package MyApp::Controller::Books;
use base 'Catalyst::Controller::Resources';
This base controller exports Catalyst action attributes to your controller, and setup collection resource as /books.
METHODS
RESERVED SUBROUTINES (ACTIONS)
- list
-
called by GET /collection request
- create
-
called by POST /collection request
- show
-
called by GET /member/{member_id} request
- update
-
called by PUT /member/{member_id} request
- destroy
-
called by DELETE /member/{member_id} request
- post
-
called by GET /collection/new request
- edit
-
called by GET /member/{member_id}/edit request
INTERNAL METHODS
- setup_collection_actions
- setup_member_actions
AUTHOR
NAKAGAWA Masaki <masaki@cpan.org>
Daisuke Murase <typester@cpan.org>
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
Catalyst::Controller, Catalyst::Controller::SingletonResource, http://api.rubyonrails.org/classes/ActionController/Resources.html