NAME

Punk::Controller - base class for Punk controllers

SYNOPSIS

package MyApp::Controller::Web::Book;
use parent 'Punk::Controller';

sub list {
    my ($c) = @_;
    my $page = $c->model('Book')->search({}, { limit => 20 });
    return $c->render('book/list', { books => $page->{rows} });
}

1;

DESCRIPTION

Controller methods are plain subs receiving the Punk::Context - no instance, no dispatch overhead; the coderef is resolved once at to_app and called directly per request. The base class marks the package as a controller and is the natural home for shared helper subs an app wants every controller to inherit.

Route targets name controllers relative to the application's Controller:: namespace: 'Web::Book#list' in MyApp resolves to MyApp::Controller::Web::Book::list. A fully qualified name (one that already starts with the namespace) passes through unchanged.

AUTHOR

LNATION <email@lnation.org>

LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by LNATION <email@lnation.org>.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)