<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    `Net::Async::HTTP::Server' - serve HTTP with `IO::Async'

SYNOPSIS
     use Net::Async::HTTP::Server;
     use IO::Async::Loop;

     use HTTP::Response;

     my $loop = IO::Async::Loop-&gt;new();

     my $httpserver = Net::Async::HTTP::Server-&gt;new(
        on_request =&gt; sub {
           my $self = shift;
           my ( $req ) = @_;

           my $response = HTTP::Response-&gt;new( 200 );
           $response-&gt;add_content( "Hello, world!\n" );
           $response-&gt;content_type( "text/plain" );

           $req-&gt;respond( $response );
        },
     );

     $loop-&gt;add( $httpserver );

     $httpserver-&gt;listen(
        addr =&gt; { family =&gt; "inet6", socktype =&gt; "stream", port =&gt; 8080 },
        on_listen_error =&gt; sub { die "Cannot listen - $_[-1]\n" },
     );

     $loop-&gt;run;

DESCRIPTION
    This module allows a program to respond asynchronously to HTTP requests,
    as part of a program based on IO::Async. An object in this class listens
    on a single port and invokes the `on_request' callback or subclass
    method whenever an HTTP request is received, allowing the program to
    respond to it.

EVENTS
  on_request $req
    Invoked when a new HTTP request is received. It will be passed a
    Net::Async::HTTP::Server::Request object.

TODO
    * Don't use HTTP::Message objects as underlying implementation

    * Consider how to do streaming request inbound

    * Lots more testing

AUTHOR
    Paul Evans &lt;leonerd@leonerd.org.uk&gt;

</pre></body></html>