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

Mojolicious::Plugin::AutoParams - Send captured placeholder values as parameters for routes.

SYNOPSIS

use Mojolicious::Lite;
use experimental 'signatures';
plugin 'auto_params';

get '/hello/:name' => sub ($c,$name) { $c->render(text => "hi, $name") }

OR

use Mojolicious::Lite;
plugin 'auto_params', { named => 1 }

get '/hello/:name' => sub {
        my $c = shift;
        my %args = @_;
        $c->render(text => "hi, $args{name}")
};

OR

use Mojolicious::Lite;
plugin 'auto_params', { named => '_' }

get '/hello/:name' => sub { shift->render(text => "hi, $_->{name}") }

DESCRIPTION

This module automatically sends placeholders as a list of parameters to routes.

By default it uses positional parameters, but it will optionally send a hash if the "named" option is set to 1.

Setting 'named' to '_' will set the local $_ to a hashref of the placeholders.

AUTHOR

Brian Duggan <bduggan@matatu.org>