-
Notifications
You must be signed in to change notification settings - Fork 277
Migration
This is the documentation which finally ends up as Dancer2::Migration POD. See Github issue #583.
The following import tags are not valid/needed anymore:
use Dancer2 qw(:syntax);
use Dancer2 qw(:tests);
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.
before
hooks will be called for files in public folder as well (see #664).
Cannot be called anymore outside register
or on_plugin_import
.
Configuration is now passed to the constructor of the engine. For example:
session: "DBIC"
engines:
session:
DBIC:
dsn: "DBI:mysql:database=testing;host=127.0.0.1;port=3306" # DBI Data Source Name
schema_class: "Interchange6::Schema" # DBIx::Class schema
You need to add the following attributes to your engine class:
has dsn => (
is => 'ro',
);
has schema_class => (
is => 'ro',
);
Use Plack::Test
, Test::WWW::Mechanize
, or Test::WWW::Mechanize::PSGI
for tests.
We cannot use read_logs
anymore as with Dancer2::Test
.