ytake / hungrr
HTTP Requesr and Response
Fund package maintenance!
ytake
Installs: 17 258
Dependents: 4
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Language:Hack
Requires
- hhvm: ^4.62
- facebook/hack-http-request-response-interfaces: ^0.3
- hhvm/hhvm-autoload: ^3.0
- hhvm/hsl: ^4.0
- hhvm/hsl-experimental: ^4.50
- ytake/extended-hack-http-request: ^0.1.2
Requires (Dev)
- facebook/fbexpect: ^2.7
- hhvm/hacktest: ^2.0
- hhvm/hhast: ^4.0
README
ytake/hungrr
is a Hack package containing implementations of the
Hack HTTP Request and Response Interfaces
PSR-7 was designed for PHP, not Hack, and some descisions do not fit smoothly with Hack's type system.
Not Supported PHP
Requirements
HHVM 4.20.0 and above.
Install
via Composer
$ composer install ytake/hungrr
Usage
Marshaling an incoming request
use type Ytake\Hungrr\ServerRequestFactory; $request = ServerRequestFactory::fromGlobals();
Response
Json Response
Constructor Detail
public function __construct( private \HH\Lib\Experimental\IO\WriteHandle $body, StatusCode $status = StatusCode::OK, dict<string, vec<string>> $headers = dict[], protected int $encodingOptions = self::DEFAULT_JSON_FLAGS )
Example
use type Ytake\Hungrr\Uri; use type Ytake\Hungrr\StatusCode; use type Ytake\Hungrr\Response\RedirectResponse; use namespace HH\Lib\Experimental\IO; list($read, $write) = IO\pipe_non_disposable(); await $write->writeAsync(\json_encode(dict[ 'testing' => dict[ 'HHVM' => 'Hack' ] ])));
Redirect Response
Constructor Detail
public function __construct(
mixed $uri,
Ytake\Hungrr\StatusCode $status,
dict<string, vec<string>> $headers
)
$uri, MUST be a string or Facebook\Experimental\Http\Message\UriInterface instance.
Example
use type Ytake\Hungrr\Uri; use type Ytake\Hungrr\StatusCode; use type Ytake\Hungrr\Response\RedirectResponse; // use uri string $r = new RedirectResponse('/foo/bar'); // use uri instance $r = new RedirectResponse(new Uri('https://example.com:10082/foo/bar'));