Skip to content
A Dancer plugin to include information from App::Cerberus
Perl
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib/Dancer/Plugin POD fixes Jul 28, 2012
.gitignore Released version 0.01 Jul 24, 2012
Changes Released version 0.03 Aug 6, 2012
README.pod Released version 0.01 Jul 24, 2012
dist.ini Released version 0.03 Aug 6, 2012

README.pod

SYNOPSIS

    use Dancer::Plugin::Cerberus;

    get '/' => sub {
        my $time_zone = vars->{cerberus}{tz}{name};
    };

DESCRIPTION

This plugin adds metadata from an App::Cerberus server to the vars before your route handlers are called.

For instance:

  • Geo-location
  • Time zone
  • User-agent info
  • Are they a spider?
  • Are they making too many requests? Should we throttle them?

It can also be configured to throttle or ban IP address ranges with App::Cerberus::Plugin::Throttle.

CONFIG

The basic configuration (servers and timeout) are passed to "new()" in App::Cerberus::Client.

    plugins:
        Cerberus:
            servers:        http://localhost:5001/

Or

    plugins:
        Cerberus:
            servers:
             -              http://host1:5001/
             -              http://host2:5001/
            timeout:        0.1

If you are using the App::Cerberus::Plugin::Throttle plugin, then you can also configure:

    plugins:
        Cerberus:
            servers:        http://localhost:5001/
            throttle:
                log_as:     info
                enforce:    0 | 1

If log_as is one of core, info, warn, debug or error, then Throttle messages will be logged at that level.

If enforce is true, then banned IP addresses will receive a 403 Forbidden response and throttled users a 503 Service Unavailable response, with a Retry-After: $seconds header.

ACCESSING CERBERUS INFO

The vars available in any route handler will contain a key cerberus with any data that App::Cerberus has returned, for instance:

    get '/' => sub {
        my $geo_info   = vars->{cerberus}{geo};
        my $time_zone  = vars->{cerberus}{tz};
        my $user_agent = vars->{cerberus}{ua};
        my $throttle   = vars->{cerberus}{throttle};
    };

SEE ALSO

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Dancer::Plugin::Cerberus

You can also look for information at:

Something went wrong with that request. Please try again.