++ed by:
CRUX AZAWAWI KENTNL XAERXESS HORNBURG

60 PAUSE users
72 non-PAUSE users.

Sawyer X

NAME

Dancer::Plugin

DESCRIPTION

Create plugins for Dancer

SYNOPSIS

  package Dancer::Plugin::LinkBlocker;
  use Dancer ':syntax';
  use Dancer::Plugin;

  register block_links_from => sub {
    my $conf = plugin_setting();
    my $re = join ('|', @{$conf->{hosts}});
    before sub {
        if (request->referer && request->referer =~ /$re/) {
            status 403 || $conf->{http_code};
        }
    };
  };

  register_plugin;
  1;

PLUGINS

You can extend Dancer by writing your own Plugin.

METHODS

register
register_plugin
plugin_setting

Configuration for plugin should be structured like this in the config.yaml of the application:

  plugins:
    plugin_name:
      key: value

If plugin_setting is called inside a plugin, the appropriate configuration will be returned. The plugin_name should be the name of the package, or, if the plugin name is under the Dancer::Plugin:: namespace, the end part of the plugin name.