Wallace Reis > CatalystX-SimpleAPI-0.04 > CatalystX::Controller::SimpleAPI

Download:
CatalystX-SimpleAPI-0.04.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

CatalystX::Controller::SimpleAPI - Catalyst controller for a simple API

SYNOPSIS ^

    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;

DESCRIPTION ^

Catalyst Controller that implements (currently only) a JSON based API.

CONFIGURATION ^

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.

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}

METHODS ^

prepare_api_request

Prepares the API request to be processed.

return_api_data

Returns the api response to the browser in JSON format.

AUTHOR & LICENSE ^

See CatalystX::SimpleAPI.

syntax highlighting: