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