Christopher H. Laco > Mango-0.01000_13 > Mango::Catalyst::Controller::REST

Download:
Mango-0.01000_13.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Mango::Catalyst::Controller::REST - Catalyst controller for REST based activity.

SYNOPSIS ^

    package MyApp::Controller::Stuff;
    use base qw/Mango::Catalyst:Controller::REST/;
    
    sub load : Local {
        my ($self, $c, $id) = @_;
        my $user = $c->model('Users')->get_by_id($id);
    
        $c->stash->{'entity'} = $user;
    };
    
    http://localhost/user/1?view=json

DESCRIPTION ^

Mango::Catalyst::Controller::REST is a base Catalyst controller that automatically enables REST activity on actions in that controller using Catalyst::Action::REST.

By default, REST looks for data in the entity stash key, for forwards to the appropriate view based on the Content-Type header, or the view parameter.

In addition to the formats supported by Catalyst::Action;:REST, the following has been added:

    Content-Type:
        'text/plain'            => [qw/View Text/],
        'text/html'             => [qw/View HTML/],
        'application/xhtml+xml' => [qw/View XHTML/],
        'application/rss+xml'   => [qw/View RSS/],
        'application/atom+xml'  => [qw/View Atom/],

    view parameter:
        txt, text => [qw/View Text/],
        htm, html => [qw/View HTML/],
        xhtml     => [qw/View XHTML/],
        rss       => [qw/View RSS/],
        atom      => [qw/View Atom/],
        json      => JSON
        yml, yaml => YAML

METHODS ^

entity

Arguments: $data, $pager

Gets/sets the entity data used for RESTish requests and responses.

wants_atom

Returns true if the client is requesting an atom feed.

wants_feed

Returns true if the client is requesting a feed (atom/rss).

wants_rss

Returns true if the client is requesting an rss feed.

wants_browser

Returns true if the client appears to be a a web browser and/or is requesting html-like resources.

wants_html

Returns true if the client is requesting html.

wants_xhtml

Returns true if the client is requesting xhtml.

wants_json

Returns true if the client is requesting json.

wants_yaml

Returns true if the client is requesting yaml.

wants_text

Returns true if the client is requesting text.

SEE ALSO ^

Catalyst::Action::REST

AUTHOR ^

    Christopher H. Laco
    CPAN ID: CLACO
    claco@chrislaco.com
    http://today.icantfocus.com/blog/
syntax highlighting: