NAME

Dancer2::Controllers

SYNOPSIS

Dancer2::Controllers is a OO (object-oriented) wrapper for defining Dancer2 routes, it allows you to define routes inside of modules that inherit from Dancer2::Controllers::Controller.

EXAMPLE

package MyApp::Controller;

use Moo;

use strict;
use warnings;

with 'Dancer2::Controllers::Controller';

sub hello_world {
    "Hello World!";
}

sub routes {
    return [ [ 'get' => '/' => 'hello_world' ] ];
}

1;

use Dancer2;
use Dancer2::Controllers qw(controllers);

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 function routes.