Added perl environment (#311)

Perl runtime environment and example function.
This commit is contained in:
Moritz Grosch (LittleFox)
2017-09-07 23:42:40 -07:00
committed by Soam Vasani
parent 1b9fa5bc30
commit 6142ac3648
4 changed files with 103 additions and 0 deletions
+18
View File
@@ -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');
};