AWS-Lambda

 view release on metacpan or  search on metacpan

examples/cgi/WwwCounter/handler.pl  view on Meta::CPAN

use utf8;
use warnings;
use strict;
use lib "$ENV{'LAMBDA_TASK_ROOT'}/local/lib/perl5";
use AWS::Lambda::PSGI;

$ENV{WWWCOUNT_DIR} ||= "/tmp";
chdir($ENV{'LAMBDA_TASK_ROOT'});
my $app = require "$ENV{'LAMBDA_TASK_ROOT'}/app.psgi";
my $func = AWS::Lambda::PSGI->wrap($app);

sub handle {
    my $payload = shift;
    return $func->($payload);
}

1;

examples/psgi/handler.pl  view on Meta::CPAN

use utf8;
use warnings;
use strict;
use AWS::Lambda::PSGI;

my $app = require "$ENV{'LAMBDA_TASK_ROOT'}/app.psgi";
my $func = AWS::Lambda::PSGI->wrap($app);

sub handle {
    my $payload = shift;
    return $func->($payload);
}

1;

lib/AWS/Lambda/PSGI.pm  view on Meta::CPAN


=head1 SYNOPSIS

Add the following script into your Lambda code archive.

    use utf8;
    use warnings;
    use strict;
    use AWS::Lambda::PSGI;

    my $app = require "$ENV{'LAMBDA_TASK_ROOT'}/app.psgi";
    my $func = AWS::Lambda::PSGI->wrap($app);

    sub handle {
        return $func->(@_);
    }

    1;

And then, L<Set up Lambda Proxy Integrations in API Gateway|https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html> or
L<Lambda Functions as ALB Targets|https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html>

xt/22_dancer.t  view on Meta::CPAN

            "user": null
        },
        "domainName": "xxxxxxxxxx.execute-api.ap-northeast-1.amazonaws.com",
        "apiId": "xxxxxxxxxx"
    },
    "body": null,
    "isBase64Encoded": false
}
EOF

my $app = require './xt/22_dancerapp.pl';
my $func = AWS::Lambda::PSGI->wrap($app);
my $input = decode_json($get_request_for_get_link);
my $ret = $func->($input);

cmp_ok($ret->{ body }, 'eq', 'https://xxxxxxxxxx.execute-api.ap-northeast-1.amazonaws.com/prod/controller1');

done_testing;

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.571 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )