{"id":26694362,"url":"https://github.com/tschaefer/openfaas-perl-mojo-template","last_synced_at":"2025-06-16T09:32:50.176Z","repository":{"id":283615072,"uuid":"951750890","full_name":"tschaefer/openfaas-perl-mojo-template","owner":"tschaefer","description":"🐳 OpenFaaS template based on the official Perl Docker image and the web framework Mojolicious.","archived":false,"fork":false,"pushed_at":"2025-03-21T06:19:46.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-21T07:25:05.841Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tschaefer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-20T07:25:06.000Z","updated_at":"2025-03-21T06:19:50.000Z","dependencies_parsed_at":"2025-03-21T07:25:11.312Z","dependency_job_id":"7418662e-328a-46cf-99f3-f06b5b9bcb63","html_url":"https://github.com/tschaefer/openfaas-perl-mojo-template","commit_stats":null,"previous_names":["tschaefer/openfaas-perl-mojo-template"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tschaefer%2Fopenfaas-perl-mojo-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tschaefer%2Fopenfaas-perl-mojo-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tschaefer%2Fopenfaas-perl-mojo-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tschaefer%2Fopenfaas-perl-mojo-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tschaefer","download_url":"https://codeload.github.com/tschaefer/openfaas-perl-mojo-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245712053,"owners_count":20660167,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-26T18:29:11.318Z","updated_at":"2025-06-16T09:32:50.121Z","avatar_url":"https://github.com/tschaefer.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenFaaS Perl Template\n\nOpenFaaS template based on the official\n[Perl Docker image](https://hub.docker.com/_/perl/) and the\n[web framework Mojolicious](https://mojolicious.org/).\n\n## Usage\nUse `faas-cli` to pull and create your Perl function.\n\n```bash\nfaas-cli template pull https://github.com/tschaefer/openfaas-perl-mojo-template\nfaas-cli new --lang perl-mojo mojo\n```\n\nEdit the **run** method in the `mojo/handler.rb` file to return some text /\nhtml.\n\n```perl\n##\n# This is the function that will be called on any request, receiving the\n# following parameters:\n#\n# $body    Contains any HTTP content.\n# $headers Hash reference of HTTP headers.\n# $params  Hash reference of URL parameters.\n#\n# The return value is a hash reference containing the response content to be\n# rendered and the HTTP status code. Optionally, it returns a hash reference\n# of custom HTTP headers.\nsub run {\n    my ($self, $body, $headers, $params) = @_;\n\n    return { text =\u003e \"Perl 🐪 Mojolicious 🚀 and OpenFaaS 🐳\", status =\u003e 200 };\n}\n```\n\nBuild and publish the function.\n\n```bash\nfaas-cli up -f stack.yml\n```\n\nTo install further OS packages or CPAN modules set the build argument in the\n`stack.yml` file.\n\n```diff\nfunctions:\n  mojo:\n    lang: perl-mojo\n    handler: ./mojo\n+    build_args:\n+      ADDITIONAL_PACKAGES: \"build-essential libssl-dev\"\n+      ADDITIONAL_CPAN_PACKAGES: \"Readonly URI\"\n```\n\n### Example\n\nPublish Minio Bucket Event to Redis Topic.\n\n```perl\npackage Handler;\n\nuse strict;\nuse warnings;\n\nuse utf8;\n\nuse Mojo::JSON qw(decode_json encode_json);\nuse Redis;\n\nsub new {\n    my $class = shift;\n    my $self = {};\n\n    return bless $self, $class;\n}\n\nsub run {\n    my $self = shift;\n    my ($body, $headers) = @_;\n\n    my $minio_bucket_event = decode_json($body);\n    my $message = {\n        EventName =\u003e $minio_bucket_event-\u003e{EventName},\n        Key       =\u003e $minio_bucket_event-\u003e{Key}\n    };\n    $self-\u003e_publish($message);\n\n    return { json =\u003e \"Ok\" , status =\u003e 200 };\n}\n\nsub _publish {\n    my $self = shift;\n    my ($message) = @_;\n\n    my $redis = Redis-\u003enew(\n        server =\u003e 'redis.example.com:8888',\n        ssl    =\u003e 1,\n    );\n    $redis-\u003eauth('password');\n    $redis-\u003epublish('minio:bucket:event', encode_json($message));\n\n    return;\n}\n\n1;\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftschaefer%2Fopenfaas-perl-mojo-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftschaefer%2Fopenfaas-perl-mojo-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftschaefer%2Fopenfaas-perl-mojo-template/lists"}