[dancer-users] Call to all Dancer2 plugin writers

Rubén Amórtegui ruben.amortegui at gmail.com
Wed Oct 14 17:34:16 BST 2015


Thanks racke and Yanick, it works as expected. :)

On Wed, Oct 14, 2015 at 9:21 AM, Yanick Champoux <yanick at babyl.dyndns.org>
wrote:

> On 2015-10-14 10:38 AM, Stefan Hornburg (Racke) wrote:
> >> I have a question about the add_route functionality,  how can I access
> to the DSL keywords? eg. param('param_name') when I'm defining the code for
> a new route?
>
> > The first parameter for the route sub is an $app object, so you can do
> for example:
>
> Yup. The 'app' object is the way to go. As Racke mentioned, it's passed
> to the coderef, and it's also available as an attribute of the plugin
> object:
>
>     sub BUILD {
>         my $plugin = shift;
>
>         $plugin->app->add_route(
>             method => 'get',
>             regexp => '/goodbye',
>             code   => sub {
>                 'farewell ' . $plugin->app->request->params->{name};
>                 # or
>                 my $app = shift;
>                 'farewell ' . $app->request->params->{name};
>             },
>         );
>
>     }
>
> `/.
>
>
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>



-- 
____________________________
Rubén Darío Amórtegui Medina
MCE - Ingeniero de Sistemas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20151014/1383bdac/attachment.html>


More information about the dancer-users mailing list