nazg / http-server-request-handler
PSR-15 like HTTP Server Request Handler Interface
Installs: 16 104
Dependents: 3
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Language:Hack
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); } }