From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

NAME

Dancer2::Controllers

SYNOPSIS

Dancer2::Controllers is a Spring-Boot esq wrapper for defining Dancer2 routes, it allows you to define routes inside of modules using method attributes.

EXAMPLE

use Moose;
sub hello_world : Route(get => /) {
"Hello World!";
}
1;
package main;
use Dancer2;
controllers( ['MyApp::Controller'] );
dance;

API

controllers

controllers( [
'MyApp::Controller::Foo',
'MyApp::Controller::Bar'
] );

A subroutine that takes a list of controller module names, and registers their routes methods, annotated by the Route attribute.