Conduit
view release on metacpan or search on metacpan
my $build = Module::Build->new(
module_name => 'Conduit',
requires => {
'perl' => '5.036',
'Future::AsyncAwait' => 0,
'Future::Buffer' => 0,
'Future::IO' => '0.17',
'Future::Selector' => 0,
'HTTP::Request' => 0,
'HTTP::Response' => 0,
'IO::Socket::IP' => 0,
'Metrics::Any' => '0.05',
'Object::Pad' => '0.800',
},
test_requires => {
'Test::Future::IO' => 0,
'Test::Metrics::Any' => 0,
'Test2::V0' => 0,
},
"requires" : {
"Module::Build" : "0.4004"
}
},
"runtime" : {
"requires" : {
"Future::AsyncAwait" : "0",
"Future::Buffer" : "0",
"Future::IO" : "0.17",
"Future::Selector" : "0",
"HTTP::Request" : "0",
"HTTP::Response" : "0",
"IO::Socket::IP" : "0",
"Metrics::Any" : "0.05",
"Object::Pad" : "0.800",
"perl" : "5.036"
}
},
"test" : {
"requires" : {
"Test2::V0" : "0",
file: lib/Conduit.pm
version: '0.03'
Conduit::Metrics:
file: lib/Conduit/Metrics.pm
version: '0.03'
requires:
Future::AsyncAwait: '0'
Future::Buffer: '0'
Future::IO: '0.17'
Future::Selector: '0'
HTTP::Request: '0'
HTTP::Response: '0'
IO::Socket::IP: '0'
Metrics::Any: '0.05'
Object::Pad: '0.800'
perl: '5.036'
resources:
license: http://dev.perl.org/licenses/
version: '0.03'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
otherwise documented.
responder
responder => $app
$response = await $app->( $request );
A code reference to the responder used for handling requests.
It will be passed an HTTP::Request instance containing the incoming
request and is expected to yield an HTTP::Response instance via a
future. As a small convenience, the server will fill in the protocol
and content_length fields of the response if they are not provided by
the responder.
psgi_app
psgi_app => $app
A code reference to the PSGI application used for handling requests.
lib/Conduit.pm view on Meta::CPAN
method port () { return $listensock->sockport; }
=head2 responder
responder => $app
$response = await $app->( $request );
A code reference to the responder used for handling requests.
It will be passed an L<HTTP::Request> instance containing the incoming request
and is expected to yield an L<HTTP::Response> instance via a future. As a
small convenience, the server will fill in the C<protocol> and
C<content_length> fields of the response if they are not provided by the
responder.
=head2 psgi_app
psgi_app => $app
A code reference to the L<PSGI> application used for handling requests.
lib/Conduit/Client.pm view on Meta::CPAN
class Conduit::Client 0.03
:strict(params);
no if $^V lt v5.40, warnings => "experimental::try", "experimental::builtin";
field $socket :param;
use Future::Buffer;
use Future::IO;
use HTTP::Request;
use HTTP::Response;
use Conduit::Metrics;
field $readbuf;
ADJUST {
$readbuf = Future::Buffer->new(
fill => sub () { Future::IO->sysread( $socket, 8192 ); },
);
}
field $server :param :inheritable;
ADJUST { builtin::weaken( $server ); }
async method read_request ()
{
defined( my $header = await $readbuf->read_until( qr/\x0D\x0A\x0D\x0A/ ) )
or return undef;
my $req = HTTP::Request->parse( $header );
my $content_length = $req->content_length // 0;
if( $content_length ) {
my $body = await $readbuf->read_exactly( $content_length );
$req->add_content( $body );
}
Conduit::Metrics->received_request( $req );
( run in 1.548 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )