NAME
Dancer2::Core::App - encapsulation of Dancer2 packages
VERSION
version 0.10
DESCRIPTION
Everything a package that uses Dancer2 does is encapsulated into a Dancer2::Core::App
instance. This class defines all that can be done in such objects.
Mainly, it will contain all the route handlers, the configuration settings and the hooks that are defined in the calling package.
Note that with Dancer2, everything that is done within a package is scoped to that package, thanks to that encapsulation.
ATTRIBUTES
plugins
server
runner_config
default_config
METHODS
register_plugin
lexical_prefix
Allow for setting a lexical prefix
$app->lexical_prefix('/blog', sub {
...
});
All the route defined within the callback will have a prefix appended to the current one.
add_route
Register a new route handler.
$app->add_route(
method => 'get',
regexp => '/somewhere',
code => sub { ... },
options => $conditions,
);
route_exists
Check if a route already exists.
my $route = Dancer2::Core::Route->new(...);
if ($app->route_exists($route)) {
...
}
routes_regexps_for
Sugar for getting the ordered list of all registered route regexps by method.
my $regexps = $app->routes_regexps_for( 'get' );
Returns an ArrayRef with the results.
AUTHOR
Dancer Core Developers
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Alexis Sukrieh.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.