NAME
Net::Async::HTTP::Server::PSGI - use PSGI applications with Net::Async::HTTP::Server
SYNOPSIS
use Net::Async::HTTP::Server::PSGI;
use IO::Async::Loop;
my $loop = IO::Async::Loop->new;
my $httpserver = Net::Async::HTTP::Server::PSGI->new(
   app => sub {
      my $env = shift;
      return [
         200,
         [ "Content-Type" => "text/plain" ],
         [ "Hello, world!" ],
      ];
   },
);
$loop->add( $httpserver );
$httpserver->listen(
   addr => { family => "inet6", socktype => "stream", port => 8080 },
)->get;
$loop->run;
DESCRIPTION
This subclass of Net::Async::HTTP::Server allows an HTTP server to use a PSGI application to respond to requests. It acts as a gateway between the HTTP connection from the web client, and the PSGI application. Aside from the use of PSGI instead of the on_request event, this class behaves similarly to Net::Async::HTTP::Server.
To handle the content length when sending responses, the PSGI implementation may add a header to the response. When sending a plain ARRAY of strings, if a Content-Length header is absent, the length will be calculated by taking the total of all the strings in the array, and setting the length header. When sending content from an IO reference or using the streaming responder CODE reference, the Transfer-Encoding header will be set to chunked, and all writes will be performed as HTTP/1.1 chunks.
PARAMETERS
The following named parameters may be passed to new or configure:
PSGI ENVIRONMENT
The following extra keys are supplied to the environment of the PSGI app:
psgix.io- 
The actual IO::Socket filehandle that the request was received on.
If the server is running under SSL for HTTPS, this will be an IO::Socket::SSL instance, so reading from or writing to it will happen in cleartext.
 net.async.http.server- 
The
Net::Async::HTTP::Server::PSGIobject serving the request net.async.http.server.req- 
The Net::Async::HTTP::Server::Request object representing this particular request
 io.async.loop- 
The IO::Async::Loop object that the
Net::Async::HTTP::Server::PSGIobject is a member of. 
SEE ALSO
PSGI - Perl Web Server Gateway Interface Specification
Plack::Handler::Net::Async::HTTP::Server - HTTP handler for Plack using Net::Async::HTTP::Server
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>