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

NAME

Catalyst::TraitFor::Request::XMLHttpRequest - A request trait for XMLHttpRequest detection support

VERSION

version 0.01

SYNOPSIS

Setting up the request trait for your application:

    package MyApp;

    use Moose;
    use CatalystX::RoleApplicator;
    use namespace::autoclean;

    extends 'Catalyst';

    __PACKAGE__->apply_request_class_roles(qw(
        Catalyst::TraitFor::Request::XMLHttpRequest
    ));

    __PACKAGE__->setup;

    1;

Using the trait in your controllers

    sub some_action : Path('foo') {
        my ($self, $ctx) = @_;

        # do something depending on the request being an XMLHttpRequest or not
        if ($ctx->request->is_xhr) {
            ...
        }
        else {
            ...
        }
    }

DESCRIPTION

This request trait adds support for detecting XMLHttpRequests to the Catalyst request.

ATTRIBUTES

is_xhr

This attribute contains a boolean value indicating whether or not the request is a XMLHttpRequest.

AUTHOR

  Florian Ragwitz <rafl@debian.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 by Florian Ragwitz.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.