The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

CatalystX::CRUD::REST - REST-style controller for CRUD

SYNOPSIS

    # create a controller
    package MyApp::Controller::Foo;
    use strict;
    use base qw( CatalystX::CRUD::REST );
    
    __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,
                    );
                    
    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

    

DESCRIPTION

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.

METHODS

edit_form

Acts just like edit() in base Controller class, but with a RESTful name.

create_form

Acts just like create() in base Controller class, but with a RESTful name.

default

Attribute: Private

Calls the appropriate method based on the HTTP method name.

req_method( context )

Internal method. Returns the HTTP method name, allowing POST to serve as a tunnel when the _http_method param is present. Since most browsers do not support PUT or DELETE HTTP methods, you can use the _http_method param to tunnel the desired HTTP method and then POST instead.

edit( context )

Overrides base method to disable chaining.

view( context )

Overrides base method to disable chaining.

save( context )

Overrides base method to disable chaining.

rm( context )

Overrides base method to disable chaining.

AUTHOR

Peter Karman, <perl at peknet.com>

BUGS

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.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc CatalystX::CRUD

You can also look for information at:

COPYRIGHT & LICENSE

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.