Catalyst-ControllerRole-At
view release on metacpan or search on metacpan
README.mkdn view on Meta::CPAN
use MooseX::MethodAttributes;
extends 'Catalyst::Controller';
with 'Catalyst::ControllerRole::At';
sub init :Via($parent) At({id:Int}/...) {
my ($self, $c) = @_;
}
sub show :Via(init) At($subname) { ... }
sub update :Via(init) At($subname) { ... }
sub delete :Via(init) At($subname) { ... }
__PACKAGE__->meta->make_immutable;
This creates four (4) URL templates:
https://localhost/thingstodo/list
https://localhost/thingstodo/:id/show
https://localhost/thingstodo/:id/update
https://localhost/thingstodo/:id/delete
lib/Catalyst/ControllerRole/At.pm view on Meta::CPAN
# Define your actions, for example:
sub global :At(/global/{}/{}) { ... } # http://localhost/global/$arg/$arg
sub list :At($action?{q:Str}) { ... } # http://localhost/user/list?q=$string
sub find :At($controller/{id:Int}) { ... } # http://localhost/user/$integer
# Define an action with an HTTP Method match at the same time
sub update :Get($controller/{id:Int}) { ... } # GET http://localhost/user/$integer
__PACKAGE__->meta->make_immutable;
=head1 DESCRIPTION
The way L<Catalyst> uses method attributes to annote a subroutine with meta
information used to map that action to an incoming request has sometimes been difficult
for newcomers to the framework. Partly this is due to how the system evolved and was
augmented, with more care towards backwards compatibility (for example with L<Maypole>, its
architectural anscestor) than with designing a forward system that is easy to grasp.
lib/Catalyst/ControllerRole/At.pm view on Meta::CPAN
use MooseX::MethodAttributes;
extends 'Catalyst::Controller';
with 'Catalyst::ControllerRole::At';
sub init :Via($parent) At({id:Int}/...) {
my ($self, $c) = @_;
}
sub show :Via(init) At($name) { ... }
sub update :Via(init) At($name) { ... }
sub delete :Via(init) At($name) { ... }
__PACKAGE__->meta->make_immutable;
This creates four (4) URL templates:
https://localhost/thingstodo/list
https://localhost/thingstodo/:id/show
https://localhost/thingstodo/:id/update
https://localhost/thingstodo/:id/delete
( run in 0.761 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )