NAME

Punk::Router::Scope - the handle an under returns

SYNOPSIS

my $admin = under '/admin' => 'Web::Auth#required';
$admin->get('/books' => 'Web::Book#admin_list');

my $super = $admin->under('/super' => 'Web::Auth#superuser');
$super->del('/books/:id' => 'Web::Book#purge');

DESCRIPTION

Scopes nest as explicit objects - no dynamic scoping. Each scope holds its full path prefix and the outer-to-inner guard chain; routes attached to it inherit both. Guards receive the context and continue on a non-reference return; a reference return short-circuits the request and is finalized like any controller return.

METHODS

new(app => $app, prefix => $prefix, guards => \@guards)

A scope. Constructed for you by the under keyword (and by an outer scope's "under"); you rarely call it directly.

under($prefix => $guard)

A nested scope.

get / post / put / patch / del / any ($path => $target)

Routes under this scope; chainable.

api ($spec, \%opts?)

An OpenAPI mount under this scope's prefix and guards; returns the mount. See Punk::Mount::OpenAPI.

websocket ($path => $target, \%opts?)

A WebSocket route under this scope; chainable. See "websocket" in Punk.

prefix

guards

Introspection.

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)