CatalystX::Controller::SimpleAPI - Catalyst controller for a simple API
package ServiceApp::Controller::API; use Moose; use namespace::autoclean; BEGIN { extends 'Catalyst::Controller' } with 'CatalystX::Controller::SimpleAPI'; __PACKAGE__->config( authkeys => { 'AE281S228D4' => { ip_check => '^10\.0\.0\.[0-9]+$', valid_applications => 'myapp', }, }, ); sub auto : Private { my ( $self, $c ) = @_; # will return false if the api did not pass authorization. return $self->prepare_api_request($c); } 1;
Catalyst Controller that implements (currently only) a JSON based API.
authkeys are a mapping of authorization keys, and an IP and application identification regexes. For a request to the API to be valid, it must contain a valid authkey, and the origin IP and app id must match the regexes associated with the authkey provided.
authkeys
If no authkeys configuration for the controller is provided, it will fall back to using the global authkeys element of the application config. $c->config->{authkeys}
$c->config->{authkeys}
Prepares the API request to be processed.
Returns the api response to the browser in JSON format.
See CatalystX::SimpleAPI.
To install CatalystX::SimpleAPI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CatalystX::SimpleAPI
CPAN shell
perl -MCPAN -e shell install CatalystX::SimpleAPI
For more information on module installation, please visit the detailed CPAN module installation guide.