Dancer2::Core::App - encapsulation of Dancer2 packages
version 0.140000
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.
Dancer2::Core::App
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.
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.
Register a new route handler.
$app->add_route( method => 'get', regexp => '/somewhere', code => sub { ... }, options => $conditions, );
Check if a route already exists.
my $route = Dancer2::Core::Route->new(...); if ($app->route_exists($route)) { ... }
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.
Dancer Core Developers
This software is copyright (c) 2014 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.
To install Dancer2, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer2
CPAN shell
perl -MCPAN -e shell install Dancer2
For more information on module installation, please visit the detailed CPAN module installation guide.