swokit/http-server

some http server tool library of the swoole

v1.0.0 2018-04-30 15:52 UTC

This package is auto-updated.

Last update: 2024-03-29 03:38:37 UTC


README

Quick Start

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Swokit\Http\Serer\HttpServer;
use Swokit\Http\Serer\Util\ClosureWrapper;
use PhpComp\Http\Message\HttpFactory;

$http = new HttpServer([
    // 
]);

$http->setRequestHandler(ClosureWrapper::create(function(ServerRequestInterface $r): ResponseInterface {
    $psr7res = HttpFactory::createResponse();
    $psr7res->write('hello. URI: '. (string)$r->getUri());
    
    return $psr7res;
}));

$http->run();

license

MIT