Skip to content
Bas Bloemsaat edited this page Aug 13, 2014 · 14 revisions

This is the documentation which finally ends up as Dancer2::Migration POD. See Github issue #583.

Import syntax

The following import tags are not valid/needed anymore:

use Dancer2 qw(:syntax);
use Dancer2 qw(:tests);

Apps

Dancer2 differs from Dancer1 with respect to handling modules. By default each module is a separate Dancer2 application with its own namespace and variables.

You can set the application name in each of your Dancer2 application modules. Different modules can be tied into the same app by setting the application name to the same value.

To set the appname directive explicitly:

package myapp;
use Dancer2;
use myapp::admin;

hook before => sub {
    var db => "...";
};

prefix undef;
get '/' => sub {...};

1;

package myapp::admin;
use Dancer2 appname => "myapp";

prefix '/admin';
get '/' => sub {...};

Without the appname directive, myapp::admin would not have access to var->{db}, in fact, when accessing "/admin" the before hook would not be executed.

Plugins

plugin_setting

Cannot be called anymore outside register or on_plugin_import.

Tests

Use Plack::Test for tests.

Logs

We cannot use read_logs anymore as with Dancer2::Test.

TODO list

This list things we need to do in the D2 eco system before we can recommend it as Dancer 1 replacement for the public.

  • Plack::Test documentation #656
  • Walk through documentation and amend copy&waste from Dancer1
Clone this wiki locally