-
-
15 Jan 2014 01:00:19 UTC
- Distribution: CatalystX-ExtJS-Direct
- Module version: v2.1.5
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues (2)
- Testers (187 / 413 / 0)
- Kwalitee
Bus factor: 0- % Coverage
- License: bsd
- Activity
24 month- Tools
- Download (18.34KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
NAME
CatalystX::Controller::ExtJS::Direct::API - API and router controller for Ext.Direct
VERSION
version 2.1.5
SYNOPSIS
package MyApp::Controller::API; use Moose; extends 'CatalystX::Controller::ExtJS::Direct::API'; 1; <script type="text/javascript" src="/api/src?namespace=MyApp.Direct"></script> <script>Ext.Direct.addProvider(Ext.app.REMOTING_API);</script>
ACTIONS
router
Every request to the API is going to hit this action, since the API's url will point to this action.
You can change the url to this action via the class configuration.
Example:
package MyApp::Controller::API; __PACKAGE__->config( action => { router => { Path => 'callme' } } ); 1;
The router is now available at
/api/callme
.src
Provides the API as JavaScript. Include this action in your web application as shown in the "SYNOPSIS". To set the namespace for the API, pass a
namespace
query parameter:<script type="text/javascript" src="/api/src?namespace=MyApp.Direct"></script>
index
This action is called when you access the namespace of the API. It will load "api" and return the JSON encoded API to the client. Since this class utilizes Catalyst::Controller::REST you can specify a content type in the request header and get the API encoded accordingly.
METHODS
api
Returns the API as a HashRef.
Example:
{ url => '/api/router', type => 'remote', actions => { Calc => { methods => [ { name => 'add', len => 2 }, { name => 'subtract', len => 0 } ] } } }
encoded_api
This method returns the JSON encoded API which is useful when you want to include the API in a JavaScript file.
Example:
Ext.app.REMOTING_API = [% c.controller('API').encoded_api %]; Ext.Direct.addProvider(Ext.app.REMOTING_API); Calc.add(1, 3, function(provider, response) { // process response });
AUTHOR
Moritz Onken <onken@netcubed.de>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2014 by Moritz Onken.
This is free software, licensed under:
The (three-clause) BSD License
Module Install Instructions
To install CatalystX::ExtJS::Direct, copy and paste the appropriate command in to your terminal.
cpanm CatalystX::ExtJS::Direct
perl -MCPAN -e shell install CatalystX::ExtJS::Direct
For more information on module installation, please visit the detailed CPAN module installation guide.