NAME

Plack::Middleware::ExtDirect - RPC::ExtDirect gateway for Plack

SYNOPSIS

In your main application, before Plack::Runner->run():

use My::Server::Side::Class;
use My::Server::Side::Class2;

In your app.psgi:

my $app = sub { ... };

builder {
   enable 'ExtDirect', api_path     => '/extdirect_api',
                       router_path  => '/extdirect_router',
                       poll_path    => '/extdirect_events',
                       remoting_var => 'Ext.app.REMOTING_API',
                       polling_var  => 'Ext.app.POLLING_API',
                       namespace    => 'myApp',    # Defaults to empty
                       auto_connect => 0,
                       no_polling   => 0,
                       debug        => 0;
   $app;
}

DESCRIPTION

This module provides RPC::ExtDirect gateway implementation for Plack environment. It is packaged as standard Plack middleware component suitable for use with Plack::Builder.

You can change some default configuration options by passing relevant parameters like shown above. For the meaning of parameters, see RPC::ExtDirect::API documentation.

Note that Ext.Direct specification requires server side implementation to return diagnostic messages only when debugging is explicitly turned on. This is why debug flag defaults to 'off' and RPC::ExtDirect returns generic error messages that do not contain any details as to where and what error has happened.

CAVEATS

For RPC::ExtDirect attribute handlers to work properly, modules that expose ExtDirect Methods should be loaded at compile time. On the other hand, Plack::Runner loads and compiles code in *.psgi at runtime, and that breaks attribute magic dust. To avoid this, just make sure you load all modules that provide Ext.Direct functionality - including Event providers - before Plack::Runner starts. The easiest way to do this is to copy plackup script and modify it a little to use all relevant modules in it.

See included code examples to see how it works.

DEPENDENCIES

Plack::Middleware::ExtDirect is dependent on the following modules: Plack, RPC::ExtDirect, JSON, Attribute::Handlers.

SEE ALSO

For more information on core functionality see RPC::ExtDirect.

For more information on Ext.Direct API see specification: http://www.sencha.com/products/extjs/extdirect/ and documentation: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.direct.Manager.

See included ExtJS examples for ideas on what Ext.Direct is and how to use it.

BUGS AND LIMITATIONS

There are no known bugs in this module. To report bugs, use CPAN RT (the best way) or just drop me an e-mail. Patches are welcome.

AUTHOR

Alexander Tokarev <tokarev@cpan.org>

COPYRIGHT AND LICENSE

Copyright (c) 2011 Alexander Tokarev.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

Included ExtJS examples are copyright (c) 2011, Sencha Inc. Example code is used and distributed under GPL 3.0 license as provided by Sencha Inc. See http://www.sencha.com/license