nazg / http-server-request-handler
PSR-15 like HTTP Server Request Handler Interface
Package info
github.com/nazg-hack/http-server-request-handler
Language:Hack
pkg:composer/nazg/http-server-request-handler
0.6.0
2020-03-31 07:56 UTC
Requires
- hhvm: ^4.41
- facebook/hack-http-request-response-interfaces: ^0.3
- hhvm/hhvm-autoload: ^3.0
- hhvm/hsl: ^4.0
- hhvm/hsl-experimental: ^4.0
Requires (Dev)
- facebook/fbexpect: ^2.7
- hhvm/hacktest: ^2.0
- hhvm/hhast: ^4.0
README
PSR-15 Like HTTP Server Request Handlers Interface For Hack
Require
HHVM 3.30.0 and above.
required hsl-experimental
Install
$ hhvm $(which composer) require nazg/http-server-request-handler
Usage
Golang style
func middleware(next http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { log.Printf("Hello World, %s", r.RequestURI) next.ServeHTTP(w, r) } }
For Hack
<?hh // strict namespace Acme\Middleware; use type HH\Lib\Experimental\IO\WriteHandle; use type Facebook\Experimental\Http\Message\ResponseInterface; use type Facebook\Experimental\Http\Message\ServerRequestInterface; use type Nazg\Http\Server\MiddlewareInterface; use type Nazg\Http\Server\RequestHandlerInterface; final class ExampleMiddleware implements MiddlewareInterface { public function process( WriteHandle $writeHandle, ServerRequestInterface $request, RequestHandlerInterface $handler, ): ResponseInterface { return $handler->handle($write, $request); } }