NAME
Test::Fake::HTTPD - a fake HTTP server
SYNOPSIS
use Test::Fake::HTTPD;
my $httpd = run_http_server {
my $req = shift;
# ...
# 1. HTTP::Response ok
return $http_response;
# 2. Plack::Response ok
return $plack_response;
# 3. PSGI response ok
return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello World' ] ];
};
printf "You can connect to your server at 127.0.0.1:%d.\n", $httpd->port;
# Stop http server automatically at destruction time.
DESCRIPTION
Test::Fake::HTTPD is a fake HTTP server module for testing.
METHODS
- new( %args )
-
Returns a new instance.
- run( $app_coderef )
-
Starts this HTTP server.
- port
-
Returns a port number of running.
FUNCTIONS
- run_http_server
-
Starts HTTP server and returns the guard instance.
my $httpd = run_http_server { my $req = shift; # ... return $res; };
AUTHOR
NAKAGAWA Masaki <masaki@cpan.org>
THANKS TO
xaicron
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.