The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Dancer2::Controllers::Controller

SYNOPSIS

Moose base class for creating controllers.

EXAMPLE

    package MyApp::Controller;

    use Moose;

    BEGIN { extends 'Dancer2::Controllers::Controller' }

    sub hello_world : Route(get => /) {
        "Hello World!";
    }

    1;

API

Route attribute

    package MyApp::Controller;

    use Moose;

    BEGIN { extends 'Dancer2::Controllers::Controller' }

    sub hello_world : Route(get => /) {
        "Hello World!";
    }

    sub foo : Route(get => /foo/bar/:id[Int]) {
        shift->request->params->{id};
    }

The route attribute is used to defined Dancer2 routes.