This library provides utilities for:
- Emitting Hack HTTP Request and Response Interfaces responses.
- Running Hack HTTP Server Request Handlers server request handlers, which involves marshaling a Hack HTTP Request and Response Interfaces ServerRequestInterface, handling exceptions due to request creation, and emitting the response returned by the composed request handler.
Inspired by zend-httphandlerrunner
HHVM 4.41.0 and above.
$ composer require nazg-hack/http-executor
use type Ytake\Hungrr\ServerRequestFactory;
use type Nazg\HttpExecutor\RequestHandleExecutor;
use type Nazg\HttpExecutor\Emitter\SapiEmitter;
use namespace HH\Lib\IO;
<<__EntryPoint>>
function main(): noreturn {
list($readHandle, $writeHandle) = IO\pipe_nd();
$executor = new RequestHandleExecutor(
$readHandle,
$writeHandle,
new ExampleRequestHandler(),
new SapiEmitter(),
ServerRequestFactory::fromGlobals()
);
$executor->run();
}