Added perl environment (#311)
Perl runtime environment and example function.
This commit is contained in:
committed by
Soam Vasani
parent
1b9fa5bc30
commit
6142ac3648
@@ -0,0 +1,18 @@
|
||||
=pod
|
||||
|
||||
You return a CODEREF from the package that will be called as your function.
|
||||
|
||||
The code in the server is something like this (simplified):
|
||||
|
||||
my $sub = require('hello.pm');
|
||||
$sub->(request);
|
||||
|
||||
As you can see, you get the L<Dancer2::Core::Request> object as first argument
|
||||
to your function. You can use it to retrieve params given to your function or
|
||||
anything else Dancer2 offers. You can also use Dancer2 and use its DSL.
|
||||
|
||||
=cut
|
||||
|
||||
return sub {
|
||||
return 'Hello, ' . (shift->param('name') // 'world');
|
||||
};
|
||||
Reference in New Issue
Block a user