Request trait to help determine RESTiness
Perl
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib/Catalyst/TraitFor/Request
t
xt
.gitignore
ChangeLog
MANIFEST
MANIFEST.SKIP
Makefile.PL
README
README.mkdn

README.mkdn

NAME

Catalyst::TraitFor::Request::IsRESTy - Request class trait for potentially "RESTy" requests

SYNOPSIS

# in your application class...
use CatalystX::RoleApplicator;
__PACKAGE__->apply_request_class_roles(qw{
    Catalyst::TraitFor::Request::IsRESTy
});

# elsewhere...
sub foo : Local {
    my ($self, $c) = @_;

    if ($c->req->is_resty) {

        # do stuff if we look like a REST request
    }

}

DESCRIPTION

IsRESTy is a Catalyst::Request trait that (essentially) adds an is_resty() method, which attempts to determine if the request "looks" like a REST request. This can be useful when, say, combining public and serialized actions in a single controller, where certain actions do / do not need to be executed based on the type of the request.

Right now, the "sniffing" logic is pretty simplistic: if the request indicates a preferred content type of anything but text/html, we're resty.

METHODS

is_resty()

Returns true/false depending on our guess of this request's RESTiness.

SETUP METHODS

resty_builder()

Gets or sets the method used to test the request for its RESTiness. Note that this controls the method used across all instances. (That is, this is a method set at the class level.)

reset_resty_builder()

Return the tester to its default.

SEE ALSO

Catalyst::Controller::Resources, Catalyst::Controller::REST can both be used together to present an effective "merged" controller.

CatalystX::RoleApplicator, Catalyst::TraitFor::Request::REST.

AUTHOR

Chris Weyl cweyl@alumni.drew.edu

LICENSE AND COPYRIGHT

Copyright (c) 2010 Chris Weyl cweyl@alumni.drew.edu

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the

Free Software Foundation, Inc.
59 Temple Place, Suite 330
Boston, MA  02111-1307  USA