add perl support,

fx up func.pl

Signed-off-by: Minghe Huang <h.minghe@gmail.com>
This commit is contained in:
Minghe Huang
2019-12-18 15:37:23 +08:00
parent 64cbbc70bb
commit 159714491d
8 changed files with 82 additions and 1 deletions

36
examples/functions/Perl/README.md vendored Normal file
View File

@@ -0,0 +1,36 @@
# Make a Perl function a service with fx
Write a function like,
```perl
sub fx {
my $ctx = shift;
return 'hello fx'
}
1;
```
then deploy it with `fx up` command,
```shell
$ fx up -p 8080:3000 func.pl
```
test it using `curl`
```shell
$ curl 127.0.0.1:8080
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 11
Content-Type: text/plain; charset=utf-8
Date: Tue, 06 Aug 2019 15:58:41 GMT
hello fx
```
### ctx
The `ctx` object is exactly the [Controller](https://mojolicious.org/perldoc/Mojolicious/Controller) of [Mojolicious](https://mojolicious.org/perldoc/Mojolicious) framework.

6
examples/functions/Perl/func.pl vendored Normal file
View File

@@ -0,0 +1,6 @@
sub fx {
my $ctx = shift;
return 'hello fx'
}
1;