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

On Wed, Oct 14, 2015 at 9:21 AM, Yanick Champoux <yanick@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@dancer.pm
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users



--
____________________________
Rubén Darío Amórtegui Medina
MCE - Ingeniero de Sistemas