Catalyst::TraitFor::Request::REST::ForBrowsers::AndPJAX - Acknowledge PJAX requests as browser requests
PJAX
This document describes version 0.001 of Catalyst::TraitFor::Request::REST::ForBrowsers::AndPJAX - released June 06, 2012 as part of Catalyst-TraitFor-Request-REST-ForBrowsers-AndPJAX.
# in your app class use CatalystX::RoleApplicator; __PACKAGE__->apply_request_class_roles(qw/ Catalyst::TraitFor::Request::REST::ForBrowsers::AndPJAX /); # then, off in an controller somewhere... sub action_GET_html { ... also called for PJAX requests ... }
This is a tiny little Catalyst::Request class trait that recognizes that a PJAX request is also a browser request, and thus looks_like_browser() also returns true when the method is GET and the X-Pjax header is present and is 'true'.
X-Pjax
This allows actions using an action class of REST::ForBrowsers to transparently handle PJAX requests, without requiring any more modification to the controller or application than applying this trait to the request class, rather than plain-old Catalyst::TraitFor::Request::REST::ForBrowsers.
This method is wrapped to return true if the method is GET and the X-Pjax header is present and is 'true'.
Otherwise we hand things off to the original method, to render its verdict as to the tenor of the request.
Please see those modules/websites for more information related to this module.
Catalyst::TraitFor::Request::REST::ForBrowsers
Catalyst::Action::REST::ForBrowsers
Plack::Middleware::Pjax
The development version is on github at http://github.com/RsrchBoy/catalyst-traitfor-request-rest-forbrowsers-andpjax and may be cloned from git://github.com/RsrchBoy/catalyst-traitfor-request-rest-forbrowsers-andpjax.git
Please report any bugs or feature requests on the bugtracker website https://github.com/RsrchBoy/catalyst-traitfor-request-rest-forbrowsers-andp jax/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Chris Weyl <cweyl@alumni.drew.edu>
This software is Copyright (c) 2012 by Chris Weyl.
This is free software, licensed under:
The GNU Lesser General Public License, Version 2.1, February 1999
To install Catalyst::TraitFor::Request::REST::ForBrowsers::AndPJAX, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::TraitFor::Request::REST::ForBrowsers::AndPJAX
CPAN shell
perl -MCPAN -e shell install Catalyst::TraitFor::Request::REST::ForBrowsers::AndPJAX
For more information on module installation, please visit the detailed CPAN module installation guide.