CatalystX::CRUD::REST - RESTful CRUD controller
# create a controller package MyApp::Controller::Foo; use strict; use base qw( CatalystX::CRUD::REST ); use MyForm::Foo; __PACKAGE__->config( form_class => 'MyForm::Foo', init_form => 'init_with_foo', init_object => 'foo_from_form', default_template => 'path/to/foo/edit.tt', model_name => 'Foo', primary_key => 'id', view_on_single_result => 0, page_size => 50, enable_rpc_compat => 0, ); 1; # now you can manage Foo objects using your MyForm::Foo form class # with URIs at: # foo/<pk> # and use the HTTP method name to indicate the appropriate action. # POST /foo -> create new record # GET /foo -> list all records # PUT /foo/<pk> -> update record # DELETE /foo/<pk> -> delete record # GET /foo/<pk> -> view record # GET /foo/<pk>/edit_form -> edit record form # GET /foo/create_form -> create record form
CatalystX::CRUD::REST is a subclass of CatalystX::CRUD::Controller. Instead of calling RPC-style URIs, the REST API uses the HTTP method name to indicate the action to be taken.
See CatalystX::CRUD::Controller for more details on configuration.
The REST API is designed with identical configuration options as the RPC-style Controller API, so that you can simply change your @ISA chain and enable REST features for your application.
IMPORTANT: If you are using a CatalystX::CRUD::REST subclass in your application, it is important to add the following to your main MyApp.pm file, just after the setup() call:
__PACKAGE__->setup(); # add these 3 lines use MRO::Compat; use mro 'c3'; Class::C3::initialize();
This is required for Class::C3 to resolve the inheritance chain correctly, especially in the case where your app is subclassing more than one CatalystX::CRUD::Controller::* class.
Acts just like edit() in base Controller class, but with a RESTful name.
Acts just like create() in base Controller class, but with a RESTful name.
Redirects to create_form().
Attribute: Path Args
Calls the appropriate method based on the HTTP method name.
Attribute: Private
Returns 404 status. In theory, this action is never reached, and if it is, will log an error. It exists only for debugging purposes.
Internal method. Returns the HTTP method name, allowing POST to serve as a tunnel when the _http_method or x-tunneled-method param is present. Since most browsers do not support PUT or DELETE HTTP methods, you can use the special param to tunnel the desired HTTP method and then POST instead.
_http_method
x-tunneled-method
Overrides base method to disable chaining.
Overrides base method to redirect to REST-style URL.
Overrides base method just to call next::method to ensure config() gets merged correctly.
Peter Karman, <perl at peknet.com>
<perl at peknet.com>
Please report any bugs or feature requests to bug-catalystx-crud at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CatalystX-CRUD. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-catalystx-crud at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc CatalystX::CRUD
You can also look for information at:
Mailing List
https://groups.google.com/forum/#!forum/catalystxcrud
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/CatalystX-CRUD
CPAN Ratings
http://cpanratings.perl.org/d/CatalystX-CRUD
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=CatalystX-CRUD
Search CPAN
http://search.cpan.org/dist/CatalystX-CRUD
Copyright 2008 Peter Karman, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install CatalystX::CRUD, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CatalystX::CRUD
CPAN shell
perl -MCPAN -e shell install CatalystX::CRUD
For more information on module installation, please visit the detailed CPAN module installation guide.