Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building a web service with Perl

I need to build a server-side application (tiny web service) for testing proposes. What are some CPAN modules and Perl libraries for implementing such task?

like image 384
smith Avatar asked Jan 31 '12 00:01

smith


1 Answers

Testing a tiny Web service with Plack::Test:

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;
like image 81
daxim Avatar answered Sep 28 '22 06:09

daxim