gpt4 book ai didi

web-services - 使用 Perl 构建 Web 服务

转载 作者:行者123 更新时间:2023-12-04 05:07:57 27 4
gpt4 key购买 nike

我需要为测试建议构建一个服务器端应用程序(小型 Web 服务)。有哪些CPAN用于实现此类任务的模块和 Perl 库?

最佳答案

使用 Plack::Test 测试一个小型 Web 服务:

use Plack::Test;
use Test::More;
test_psgi(
app => sub {
my ($env) = @_;
return [200, ['Content-Type' => 'text/plain'], ["Hello World"]],
},
client => sub {
my ($cb) = @_;
my $req = HTTP::Request->new(GET => "http://localhost/hello");
my $res = $cb->($req);
like $res->content, qr/Hello World/;
},
);
done_testing;

关于web-services - 使用 Perl 构建 Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9072959/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com